Skip to content

Template for API that uses PostgreSQL-database / Шаблон API, использующего базу данных PostgreSQL

License

Notifications You must be signed in to change notification settings

amozebus/fastapi-beyond-crud-2

Repository files navigation

FastAPI Beyond CRUD 2 (with PostgreSQL)

Code style: black

Template for API that uses PostgreSQL-database. Written in Python with FastAPI, asyncpg as database client, SQLModel as ORM

Included Alembic for database migrations

Users' passwords hashing with BCrypt and users authorization with access JWTs

How to run

  1. Rename .env.example to .env and fill fields

    • Fields:
    DATABASE_URL (str): PostgreSQL-database URL
    
    JWT_SECRET (str): secret for JWTs signature
    
    ACCESS_TOKEN_EXPIRE (int): access JWTs expire time in seconds
    
  2. Install dependencies:

pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head
  1. Run app:
python src/main.py

Docker

  1. Build Docker image:
docker build . --tag api
  1. Run Docker image:
docker run -d api
  1. Run database migrations:
docker exec {container id} alembic upgrade head

About

Template for API that uses PostgreSQL-database / Шаблон API, использующего базу данных PostgreSQL

Topics

Resources

License

Stars

Watchers

Forks