On Postgres 15, give rights on public schema for the current user:
GRANT ALL ON SCHEMA public TO dev;Next, generate the migrations:
alembic revision --autogenerate -m "New Migration"alembic upgrade headuvicorn main:app --reloadNext, go to SWAGGER UI http://localhost:8000/docs
Build the image:
docker build -t fastapi .Then, run the image:
docker run -e DATABASE_URL='postgresql://driver://user:pass@localhost/dbname' -p 8080:8080 fastapihttps://www.educative.io/answers/how-to-use-postgresql-database-in-fastapi