Skip to content

Latest commit

 

History

History

README.rst

Tortoise-ORM FastAPI example

We have a lightweight integration util tortoise.contrib.fastapi which has a class RegisterTortoise that can be used to set/clean up Tortoise-ORM in lifespan context.

Setup

Initialize the migrations directory (one-time, already done in this example):

python -m tortoise -c config.TORTOISE_ORM init

Create migrations when models change:

python -m tortoise -c config.TORTOISE_ORM makemigrations

Apply migrations to the database:

python -m tortoise -c config.TORTOISE_ORM migrate

Run

uvicorn main:app --reload