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.
- Install dependencies
pip install -r requirements.txt-
Create a
config.ymlfile (copyingconfig.yml.exampleshould be enough) -
Run a database container
python app/db/container.py run- Apply database migrations
python app/db/db_setup.py upgrade- Start a development server
fastapi dev app/main.pyTest cases are implemented with Pytest. Some test cases use the Postgresql container for creating temporary databases.
# 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>]python path/to/test/file# 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# 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>]