r/FastAPI • • Aug 21 '21

Question Shell for Fast api ?

There is shell in django , My teams wants the same for Fast api. I tried with IPython but the problem is I can't use Tortoise orm Queries as it says database has no connection and other stuff. My question : Is there any way to make or install a shell for fast api project.

11 Upvotes

12 comments sorted by

View all comments

3

u/pytheous1988 Aug 22 '21

I guess my first question would be, what do you need the shell for? It's more likely you are trying to interact with the database in some way. The best thing to do would be to build out commands in click to your ORM layer or choice that does what you need it to do.

1

u/Impressive-Hat1494 Aug 22 '21

can you tell, how can I do that ?

2

u/pytheous1988 Aug 22 '21

Click is a library that allows you to build CLI commands easily. You use it to interact with the ORM. So say you needed to add a new user. You could build a command that is like python ORM.py create_user first_name last_name email and under the hood it uses the ORM commands to take those arguments and insert a new user row into your db.