Skip to content

testdrivenio/fastapi-tortoise-aerich

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI + Tortoise-ORM + Aerich

Quick example of FastAPI with Tortoise and Aerich (for migration support).

Quick Start

Build the image and spin up the web (FastAPI + Uvicorn) and web-db (Postgres) containers:

$ docker-compose up -d --build

Ensure http://localhost:8002/ping works:

{
    "ping": "pong!"
}

Init Aerich:

$ docker-compose exec web aerich init -t db.TORTOISE_ORM

Create the first migration and apply it to the database:

$ docker-compose exec web aerich init-db

Create Migration

Make a change to the model. Then, run:

$ docker-compose exec web aerich migrate
$ docker-compose exec web aerich upgrade

Postgres

Want to access the database via psql?

$ docker-compose exec web-db psql -U postgres

Then, you can connect to the database and run SQL queries. For example:

# \c web
# select * from event;

About

Quick example of FastAPI with Tortoise (ORM) and Aerich (for migration support)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published