Skip to main content

A template package template.

Project description

SQLAlchemy FastAPI HTTP Exceptions

Python UV Hatchling Ruff Pre-commit Pytest Coverage GitHub Actions PyPI Makefile

🦜🕸️

CI


Table of Contents


Introduction

Auto HTTP Exception Mapping for SQLAlchemy errors in FastAPI


Quick Start

Since this is just a package, and not a service, there is no real "run" action. But you can run the tests immediately.

Here are a list of available commands via make.

Bare Metal (i.e. your machine)

  1. make install - install the required dependencies.
  2. make test - runs the tests.

Docker

  1. make build-docker - build the docker image.
  2. make run-docker - run the docker compose services.
  3. make test-docker - run the tests in docker.
  4. make clean-docker - remove all docker containers etc.

Installation

For Dev work on the repo

Install uv, (if you haven't already) https://docs.astral.sh/uv/getting-started/installation/#installation-methods

brew install uv

Initialise pre-commit (validates ruff on commit.)

uv run pre-commit install

Install dependencies (including dev dependencies)

uv sync

If you are adding a new dev dependency, please run:

uv add --dev {your-new-package}

Namespaces

Packages all share the same namespace ab_core. To import this package into your project:

from ab_core.sqlalchemy_fastapi_http_exceptions import placeholder_func

We encourage you to make your package available to all of ab via this ab_core namespace. The goal is to streamline development, POCs and overall collaboration.


Usage

Adding the dependency to your project

The library is available on PyPI. You can install it using the following command:

Using pip:

pip install ab-sqlalchemy-fastapi-http-exceptions

Using UV

Note: there is currently no nice way like poetry, hence we still needd to provide the full url. https://github.com/astral-sh/uv/issues/10140

Add the dependency

uv add ab-sqlalchemy-fastapi-http-exceptions

Using poetry:

Then run the following command to install the package:

poetry add ab-sqlalchemy-fastapi-http-exceptions

How tos

Example Usage

# Please update this based on your package!

from ab_core.sqlalchemy_fastapi_http_exceptions import placeholder_func


if __name__ == "__main__":
    print("This is a placeholder: ", placeholdder_func())

Formatting and linting

We use Ruff as the formatter and linter. The pre-commit has hooks which runs checking and applies linting automatically. The CI validates the linting, ensuring main is always looking clean.

You can manually use these commands too:

  1. make lint - check for linting issues.
  2. make format - fix linting issues.

CICD

Publishing to PyPI

We publish to PyPI using Github releases. Steps are as follows:

  1. Manually update the version in pyproject.toml file using a PR and merge to main. Use uv version --bump {patch/minor/major} to update the version.
  2. Create a new release in Github with the tag name as the version number. This will trigger the publish workflow. In the Release window, type in the version number and it will prompt to create a new tag.
  3. Verify the release in PyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file ab_sqlalchemy_fastapi_http_exceptions-0.1.0.tar.gz.

File metadata

File hashes

Hashes for ab_sqlalchemy_fastapi_http_exceptions-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a50fe247039bde00c9a25fcc11b2a35988aecaa56b7c4db2c84db3910cb21a01
MD5 f5e8e5c6eec8dd21bb556ee1e3410d8e
BLAKE2b-256 c2a4218f9a112b293e2e1a71774efa150d7e293b0cd09d50d85ba2c48f11de7f

See more details on using hashes here.

File details

Details for the file ab_sqlalchemy_fastapi_http_exceptions-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ab_sqlalchemy_fastapi_http_exceptions-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 08a864a37a80ce774b4be479b7e20aae109902003ef8f4dde109791440a68824
MD5 f1aa545c746c896d3cd6e73897dee369
BLAKE2b-256 60bb77091b754cf36eb2793df95a50b3a17ab21a87f3327cfd7565ae6757968e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page