FastAPI A FastAPI application with SQLAlchemy and PostGreSQL.
Sample Setup Create a virtual environment using virtualenv module in python.
pip install virtualenv
virtualenv --python= venv
source venv/bin/activate
pip install -r requirements.txt Configure .env file Setup a postgres docker container docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD= -d postgres:14 At app directory, run alembic migration command. Please make sure your postgres DB is ready and accessible. In case you want to use SQLite instead, please be sure to configure the env.py file in alembic folder to support batch execution since SQLite does not support ALTER command, which is needed to configure the foreign key and establish the indexes.
alembic upgrade head
alembic downgrade <revision_number>
alembic downgrade base
alembic revision -m Run uvicorn web server from app directory (reload mode is for development purposes) uvicorn main:app --reload