You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
a8eec38beb | 3 years ago | |
---|---|---|
.. | ||
project | 3 years ago | |
.gitignore | 3 years ago | |
LICENSE | 3 years ago | |
README.md | 3 years ago | |
docker-compose.yml | 3 years ago |
README.md
FastAPI + SQLModel + Alembic
Following the https://testdriven.io/blog/fastapi-sqlmodel/ blog post
Docker Containers
Bring it up
docker-compose up -d --build
Shut it down
docker-compose down -v
The -v removes names volumes declared in the volumes
section of the compose
file and anonymous volumes attached to containers
Logs
docker-compose logs web
You'll see what is logged to stdout. Should include your new models on startup.
or
docker-compose logs db
PSQL for working in your DB
docker-compose exec db psql --username=postgres --dbname=foo
foo=# \dt
List of relations
Schema | Name | Type | Owner
--------+------+-------+----------
public | song | table | postgres
Interactions with API
Add a song
curl -d '{"name":"Midnight Fit", "artist":"Mogwai"}' \
-H "Content-Type: application/json" -X POST http://localhost:8004/songs
Response:
{"id":1,"artist":"Mogwai","name":"Midnight Fit"}%
Sources Root in Pycharm
I marked "project" directory as the "Sources Root". PyCharm uses the source roots as the starting point for resolving imports.