sample backend using pyfastapi, sqlalchemy, and alembic
- python 3.12
- poetry
- sqlite
- install dependencies
poetry install - copy
.env.exampleto.envand change the values if needed - run the app
poetry run python run.py - call the api endpoint
curl http://localhost:5000/persons - open
http://localhost:5000/docsto view then openapi docs
- build the image
podman build -t pyfastapi . - run the image
podman run -p 5000:5000 pyfastapi
note: you can use docker instead of podman as it is a drop in replacement
- run
alembic upgrade head - sql schema and the data should be on
./sql_app.db - refer to
alembic.inito change other configuration, it uses .env for the DB url
- make sure main dependencies are installed
- run
poetry install - run
pytest, take note that it uses.env.testfor configuration
---
config:
layout: dagre
look: handDrawn
title: ERD
---
erDiagram
person {
int id PK ""
String last_name ""
String first_name ""
String country_code FK ""
timestamp updated_at ""
timestamp created_at ""
}
country {
String code PK ""
String name ""
int phone ""
String symbol ""
String capital ""
String currency ""
String continent_code FK ""
String alpha_3 ""
timestamp updated_at ""
timestamp created_at ""
}
continent {
String code PK ""
String name ""
}
person}|--||country:"residesIn"
country}|--||continent:"belongsTo"