Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to tinker with app when developping #1049

Closed
3 tasks done
robido opened this issue Feb 28, 2020 · 4 comments
Closed
3 tasks done

how to tinker with app when developping #1049

robido opened this issue Feb 28, 2020 · 4 comments
Labels
question Question or problem question-migrate

Comments

@robido
Copy link

robido commented Feb 28, 2020

First check

  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to interact with FastAPI app" and didn't find any information.

Description

I have a few SQLAlchemy models in my fastAPI app, and let's say I want to experiment, for instance, I want to develop a filter, and I need to tinker with the code to try a few things. How can I do that without having to create Schemas and endpoints for a model I just want to play with?

Additional context

The FastAPI docs give a method for debugging, would it be one way to handle it? Pause the program then write custom commands. Essentially, I am asking if there is the equivalent of an interactive shell, similar to what Django, Flask, or Laravel (tinker) offer. If not, what is the recommended workflow to tinker with models?

@robido robido added the question Question or problem label Feb 28, 2020
@Kilo59
Copy link

Kilo59 commented Feb 29, 2020

You can run uvicorn with --reload and it will redeploy a local development server everytime it detects a source file has changed.

uvicorn your_package.main:app --reload

https://www.uvicorn.org/deployment/

@robido
Copy link
Author

robido commented Feb 29, 2020

Thanks @Kilo59 I tried that, but I get this error:
sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured on mapper mapped class User->user, SQL expression or this Session

I am using this repo: https://github.com/tiangolo/full-stack-fastapi-postgresql. The code works fine in Docker, so if I go to http://localhost/api/v1/users I get the expected results, but http://localhost:8000/api/v1/users shows the above error.

I'll try this now see if that helps:
fastapi/full-stack-fastapi-template#7

@tiangolo
Copy link
Member

What I would do is using VS Code, start an "Interactive Session", that's actually Jupyter underneath, that I think is more powerful than any other Python interactive shell, and then I would run commands there interactively, or actually, select sections of code in the editor and execute them in the interactive session (with Shift+Enter).

Check more info here: https://code.visualstudio.com/docs/python/jupyter-support

@github-actions
Copy link
Contributor

Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.

@tiangolo tiangolo changed the title [QUESTION] how to tinker with app when developping how to tinker with app when developping Feb 24, 2023
@tiangolo tiangolo reopened this Feb 28, 2023
@fastapi fastapi locked and limited conversation to collaborators Feb 28, 2023
@tiangolo tiangolo converted this issue into discussion #7621 Feb 28, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Question or problem question-migrate
Projects
None yet
Development

No branches or pull requests

3 participants