Pogchamp-company / fastapi-async-sqlalchemy-template

Fastapi template included sqlalchemy 2.0 and pytest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ProjectName

Description

Your project description

Getting Started

Prerequisites

  1. Python3
  2. PostgreSQL

Install & Run project

  1. Clone repo
git clone Your project url
  1. Create Python Virtual Environment
  2. Install requirements
pip install -r requirements/requirements.txt
  1. Create PostgreSQL database
  2. Make .env file
touch .env
  1. Set env variables
  2. Migrate database
# cd src
alembic upgrade head
  1. Run project
source venv/bin/activate
python manage.py serve --workers 1

Run tests

  1. Install tests requirements
pip install -r requirements/test_requirements.txt
  1. Create db with prefix "test_"
  2. Run pytest
source venv/bin/activate
pytest

Tests coverage

pytest --cov=app --cov-report=html --cov-config=.coveragerc tests/ 

Contributing

Code style

pep8 FastAPI Best Practices

Branch naming

{username}/{task_short_description}

Environment variables

Variable Description Default
DATABASE_URI PostgreSQL URI postgresql+asyncpg://postgres@localhost:5432/db_name
BACKEND_CORS_ORIGINS Frontend []
HOST - 127.0.0.1
PORT - 8000
DEBUG - False

Project structure

Project structure id described here

About

Fastapi template included sqlalchemy 2.0 and pytest


Languages

Language:Python 97.2%Language:Mako 1.8%Language:Shell 1.0%