Skip to content

An example setup of a FastAPI web app with SQLAlchemy ORM and Alembic migration management system

Notifications You must be signed in to change notification settings

AlexShein/fastapi-sqlalchemy-alembic-demo

Repository files navigation

Description

This is a basic FastAPI web app example with SQL Alchemy ORM and Alembic migration management system.

Usage

Dependencies installation

Go to the project folder and run poetry install.

Code checks

Ruff and Black tools are used. Run make checks to autoformat and lint the code.

Running the app

DB

Run make db-up to spin up a Postgres docker image.

DB migrations

Apply DB migrations by running poetry run alembic upgrade head

API

Run make run to start the API.

Tests

Run make test-db-up to spin up the test DB, then run make test

ERD

erDiagram
    User ||--o{ Note : ""
    Note {
        number user_id
    }

    User ||--o{ UserDocument : "has 0-n documents via"
    User {
        number id
    }

    UserDocument }o--|| Document : ""
    UserDocument {
        number user_id
        number document_id
    }
    Document {
        number id
    }
Loading

Useful documentation

SQL Alchemy documentation

Alembic how-to

Related objects documentation

Calculated columns

About

An example setup of a FastAPI web app with SQLAlchemy ORM and Alembic migration management system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published