Skip to content

tisauro/FastAPI-Blueprint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Development

Requirements

  • Docker
  • EnvFile plugin for Pycharm: File -> Settings -> Plugins Search for EnvFile, install and restart IDE if required
  • Python 3.9 virtual environment
  • if using Postgres: in order to pip install psycpg2 we need sudo apt-get install libpq-dev

Install requirements

  pip install -e .
  pip install -e ".[dev]"

Static tests

  • run static tests with:
    ruff check --fix
    ruff format

Run tests

    pytest

Start project in Debug mode

  • open docker-compose and run the MariaDB database service
  • from the root folder in the activated virtual environment run pip install -r requirements.txt
  • Create a new python run configuration as per image below, note we add the environment variables listed in the .env_sample file, this will pass all the required info to connect to the local database img.png

Todo:

  • add inizialization script to docker to run migrations and database creation
  • cors
  • fix test unit not running with settings override

Logs middleware

in order to pip install psycpg2 we need sudo apt-get install libpq-dev

alembic commands:

Full documentation can be found in here:

  • init script to be run only once: alembic init alembic as pert of the configuration we change the alembic.ini file specifying the file template name as: file_template = %%(epoch)s_%%(slug)s

  • create a migration script: alembic revision --autogenerate -m "create account table"

  • running migration: alembic upgrade head

  • partial revision identifier: alembic upgrade ae1 only part of the revision no can be specified as far as it is enough to identify a specific revision.

  • relative migration identifiers: alembic upgrade +2

  • getting information: alembic current and alembic history --verbose

  • downgrading: alembic downgrade base base is a key work to downgrade to the beginning otherwise run alembic downgrade revision_no

About

Blueprints for FastAPI projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published