Skip to content

Sample FastAPI project that uses async SQLAlchemy, SQLModel, Postgres, Alembic, and Docker.

License

Notifications You must be signed in to change notification settings

doubledare704/fastapi-sqlmodel-alembic

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI + SQLModel + Alembic

Sample FastAPI project that uses async SQLAlchemy, SQLModel, Postgres, Alembic, and Docker.

Want to learn how to build this?

Check out the post.

Want to use this project?

$ docker-compose up -d --build
$ docker-compose exec web alembic upgrade head

Sanity check: http://localhost:8004/ping

Add a hero:

$ curl -d '{"name":"Midnight Fit", "secret_name":"Mogwai", "age":"30"}' -H "Content-Type: application/json" -X POST http://localhost:8004/heroes

Get all songs: http://localhost:8004/heroes

Changelog for my fork of original FastAPI + SQLModel + Alembic boilerplate:

  • Used test model from sqlmodel example
  • Updated packages
  • Updated codebase to use new Model, stop using deprecated code (async engine in sqlmodel is not available now, used alchemy instead)
  • Updated postgresql image version
  • Renamed source folder to backend (for cases if someone uses monorepo for front-end and backend)

Plan to update this repo from time to time.

Features to implement:

  • Separate DB queries from routers methods (start using db repository classes)
  • add testing folder and settings
  • add visual docs folder with auto-generation of uml class models

About

Sample FastAPI project that uses async SQLAlchemy, SQLModel, Postgres, Alembic, and Docker.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 90.3%
  • Mako 5.3%
  • Dockerfile 4.4%