diff --git a/README.md b/README.md index 84100ff..e5f3bfa 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ # 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](https://testdriven.io/blog/fastapi-sqlmodel/). + +## Want to use this project? + +```sh +$ docker-compose up -d --build +$ docker-compose exec web alembic upgrade head +``` + +Sanity check: [http://localhost:8004/ping](http://localhost:8004/ping) + +Add a song: + +```sh +$ curl -d '{"name":"Midnight Fit", "artist":"Mogwai", "year":"2021"}' -H "Content-Type: application/json" -X POST http://localhost:8004/songs +``` + +Get all songs: [http://localhost:8004/songs](http://localhost:8004/songs) diff --git a/project/app/main.py b/project/app/main.py index f096aa5..2b24454 100644 --- a/project/app/main.py +++ b/project/app/main.py @@ -2,7 +2,7 @@ from fastapi import Depends, FastAPI from sqlalchemy.future import select from sqlalchemy.ext.asyncio import AsyncSession -from app.db import get_session, init_db +from app.db import get_session from app.models import Song, SongCreate app = FastAPI()