Skip to content

Latest commit

 

History

History
75 lines (51 loc) · 1.26 KB

File metadata and controls

75 lines (51 loc) · 1.26 KB

Installation without Docker

Env file

Create .env file in root directory :

ENV=development

PROJECT_NAME=FastAPI Skeleton
APP_VERSION=1.0.0

DATABASE_USER=app
DATABASE_PASSWORD=password
DATABASE_URL=127.0.0.1
DATABASE_NAME=skeleton
DATABASE_PORT=5432

Installation without docker

Use at least python 3.10.

Create a virtualenv and activate it

python3 -m venv venv
source venv/bin/activate

Install requirements

pip3 install -r requirements/dev.txt # or prod.txt

Install/Configure PostgreSQL

Install PostgreSQL here.

And then create a database/user :

CREATE DATABASE app
CREATE USER app WITH PASSWORD 'password';

Database migration

If there is no versions in migrations/versions folder, execute this command :

# Generate version file
alembic revision --autogenerate -m "init"

Generate tables with Alembic

To apply your migration file to the database :

alembic upgrade head

In case of error : FAILED: Can't locate revision identified by '747e6da84866' you might delete entry in alembic_version table :

$ docker exec -it postgres-app psql -U app
DELETE FROM alembic_version;

Start FastAPI app

python3 main.py