Skip to content

A repository for storing FastAPI code and projects while learning. Includes exercises, tutorials, and practice projects.

Notifications You must be signed in to change notification settings

rjcli/fast-api-playground

Repository files navigation

Fast API Playground Repository

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.

Topics

  • Python Refresher

Important Commands

  • 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 /docs route.

Sqlite Database Commands

  • sqlite3 <database_name.db> to run the database in terminal.
  • .schema to see the database schemas.
  • Here, you can use SQL commands to insert, delete, update and see the data.
  • Different .mode can be used to see the database in different formats.

    .mode column
    .mode markdown
    .mode box
    .mode table

Alembic setup

  • 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_id will be created in the previous step.
  • To downgrade - write downgrade function to downgrade the database and run the command alembic downgrade -1.

Pytest setup

  • If you have only one test file, then you can run that test file using pytest command only.
  • If you have multiple test files, then to run a test file, use the command: pytest <file_name.py>

Requirements

  • To list all the package requirements, you can use this command: pip freeze > requirements.txt. This command will create a new text file named requirements.txt and will list all the packages in that text file.

Credits

This repository follows the Udemy Course FastAPI - The Complete Course 2024 (Beginner + Advanced) by Eric Roby and Chad Darby.

About

A repository for storing FastAPI code and projects while learning. Includes exercises, tutorials, and practice projects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published