Welcome to my FastAPI Learning repository! This repository is dedicated to helping me learn and practice FastAPI. It contains a variety of exercises and tutorial codes designed to enhance my understanding of FastAPI.
- Python Refresher
- To run a FastAPI file using
uvicorn, use the following command:
uvicorn <file_name>:<fastapi_app> --reload--reload makes sure that after making the changes, the FastAPI app reloads automatically.
- To run a FastAPI file using
fastapi, use the following command:
fastapi run <file_name> # This will run the app in production mode.
fastapi dev <file_name> # This will run the app in development mode.To see all the routes of an API, use
/docsroute.
sqlite3 <database_name.db>to run the database in terminal..schemato see the database schemas.- Here, you can use SQL commands to insert, delete, update and see the data.
- Different
.modecan be used to see the database in different formats..mode column
.mode markdown
.mode box
.mode table
- To setup alembic, use the command:
alembic init alembic. - To revise the database using alembic, use the command:
alembic revision -m '<Your_Message>' - To upgrade - write upgrade function to upgrade the database and run the command
alembic upgrade <revision_id>.revision_idwill be created in the previous step. - To downgrade - write downgrade function to downgrade the database and run the command
alembic downgrade -1.
- If you have only one test file, then you can run that test file using
pytestcommand only. - If you have multiple test files, then to run a test file, use the command:
pytest <file_name.py>
- To list all the package requirements, you can use this command:
pip freeze > requirements.txt. This command will create a new text file namedrequirements.txtand will list all the packages in that text file.
This repository follows the Udemy Course FastAPI - The Complete Course 2024 (Beginner + Advanced) by Eric Roby and Chad Darby.