Skip to main content

Pyramid SQLAlchemy Integration

Project description

pyramid-sa

Pyramid SQLAlchemy Integration — a reusable library that wires SQLAlchemy into any Pyramid application.

Features

  • Session management — engine, transaction-managed sessions, request.dbsession
  • Declarative baseBase with naming conventions and utility methods (as_dict, copy_with)
  • Audit trail — opt-in AuditMixin tracking created/updated by whom and when
  • Soft delete — opt-in SoftDeleteMixin with query filtering, unique indexes, and safe restore
  • Error mappingNoResultFound → 404, IntegrityError → 409, with customizable bodies
  • JSON renderingdatetime, date, UUID adapters out of the box
  • Alembic scaffolddb init-alembic for pre-wired migration setup
  • CLI commandsdb drop, db initialize for schema management
  • Test fixtures — companion pyramid-sa-testing package with PostgreSQL-backed pytest plugin

Documentation

Full documentation is available at tomascorrea.github.io/pyramid-sa.

  • Getting Started — installation, app factory wiring, what include sets up
  • ModelsBase vs Model, as_dict(), copy_with(), mixins
  • Database & Migrations — Alembic scaffold, CLI commands, env.py setup
  • Audit TrailAuditMixin columns and automatic field population
  • Soft DeleteSoftDeleteMixin, filtering, unique indexes, restore
  • Error Handling — exception tween, custom error formatters
  • Testing — pytest fixtures, transaction isolation, conftest.py setup
  • API Reference — full public API by module

Installation

pip install pyramid-sa

For test fixtures (dev only):

pip install pyramid-sa-testing

Quick Start

Wire pyramid-sa into your Pyramid app factory:

from pyramid.config import Configurator


def create_app(global_config=None, dbengine=None, **settings):
    config = Configurator(settings=settings)

    if dbengine is not None:
        config.registry["dbengine"] = dbengine

    config.include("pyramid_sa")
    config.sa_enable_audit()          # optional: auto-populate audit fields
    config.sa_enable_soft_delete()    # optional: soft-delete behavior
    config.sa_scan_models("myapp.models")

    config.scan(".views")
    return config.make_wsgi_app()

See Getting Started for a full walkthrough of what config.include("pyramid_sa") sets up, model definitions, and next steps.

Development

uv sync --dev
uv run pytest
uv run ruff check .
uv run black .

License

MIT

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

pyramid_sa-0.7.2.tar.gz (93.6 kB view details)

Uploaded Source

Built Distribution

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

pyramid_sa-0.7.2-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file pyramid_sa-0.7.2.tar.gz.

File metadata

  • Download URL: pyramid_sa-0.7.2.tar.gz
  • Upload date:
  • Size: 93.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyramid_sa-0.7.2.tar.gz
Algorithm Hash digest
SHA256 56d8350d4723697a232c4a00e53c9cbc4a0a4dc47372d8aa637dea404011b112
MD5 ce62af06445be41fdedcc165180ba9c3
BLAKE2b-256 cc489a1862b60428bc7dc9a7a7ddc9bf908fc1f22e26cd8b035914dc570e0326

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyramid_sa-0.7.2.tar.gz:

Publisher: ci.yml on tomascorrea/pyramid-sa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyramid_sa-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: pyramid_sa-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyramid_sa-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6d5f88051311962a9b5a3685106ed9aa35f5a236ebd5b8cfd8a318323d5d0205
MD5 11776fd6e9eba337ec531c88e2e0d2d9
BLAKE2b-256 db7c576a54f3038dda6bf81d980ac3db56049078cd5ada6e5aff1611cbf069ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyramid_sa-0.7.2-py3-none-any.whl:

Publisher: ci.yml on tomascorrea/pyramid-sa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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