Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flask python manage.py shell equivalent in fastapi

I am using python manage.py shell in my flask application to use IPython shell for accessing my application from shell. Is there any equivalent for this in fastApi?

like image 239
Bharadwaj Poduri Avatar asked Jan 29 '26 04:01

Bharadwaj Poduri


1 Answers

If you want to interact with orm models directly, you can run main.py in interactive mode and import all your models there.

To enter interactive mode, run

python3 -i app/app/main.py

-i flag allows you to

enter interactive mode after executing the script or the command

After entering the interactive shell, you can import all the models using

from app.models import *

Note that your models structure might be different so you have to change the above import accordingly. In my case all the models was imported in __init__.py file, that's why I could import all of them in one go.

like image 116
Krishna Avatar answered Jan 30 '26 17:01

Krishna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!