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.9.0.tar.gz (110.4 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.9.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyramid_sa-0.9.0.tar.gz
  • Upload date:
  • Size: 110.4 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.9.0.tar.gz
Algorithm Hash digest
SHA256 56dbc5d0d2e26e389f141f8ae3fe7e44443d1bb89e8485be38213b859cae5994
MD5 f4b63dd017e3644acb9594861fd9d06d
BLAKE2b-256 b9e2dc1e476697d14796024e5c295c2a26eef548e5efb75fe9640126aa6d6d51

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyramid_sa-0.9.0.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.9.0-py3-none-any.whl.

File metadata

  • Download URL: pyramid_sa-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 16.5 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.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2f07a6d5ca06218c424487e92672951f500859bbafc377f107946a42f778d56
MD5 a6717dd453dcc3ad80b0de9c44aecd73
BLAKE2b-256 2b63e8c4ef5f066fc9751c9389ded0bd54837f8ee2ace3e14889d57320525e19

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyramid_sa-0.9.0-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