Skip to content

gsoldatov/fastapi_sqlmodel_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

A simple API implemented using FastAPI, SQLModel and a Postgresql container for storing data.

Project configuration is stored in config.yml file inside the project root directory.

Project Setup for Development

  1. Install dependencies
pip install -r requirements.txt
  1. Create a config.yml file (copying config.yml.example should be enough)

  2. Run a database container

python app/db/container.py run
  1. Apply database migrations
python app/db/db_setup.py upgrade
  1. Start a development server
fastapi dev app/main.py

Running Tests

Overview

Test cases are implemented with Pytest. Some test cases use the Postgresql container for creating temporary databases.

Run Tests via "tests" Module

# Run all test cases
python -m tests

# Run specific test files with additional pytest args
python -m tests path/relative/to/tests/tests [<additional pytest args>]

Run a Test File Directly

python path/to/test/file

Other

Postgresql Container Management

# Run or start the container
python app/db/container.py run

# Stop the container
python app/db/container.py stop

# Remove the container with data
python app/db/container.py remove

Development Database Management

# Create a new Alembic revision
python app/db/db_setup.py revision <revision_message>

# Upgrade development database to a revision (to head, if revision is omitted)
python app/db/db_setup.py upgrade [<revision>]

# Downgrade development database to a revision (to base, if revision is omitted)
python app/db/db_setup.py downgrade [<revision>]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published