Skip to main content

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 base — Base 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 mapping — NoResultFound → 404, IntegrityError → 409, with customizable bodies
  • JSON rendering — datetime, date, UUID adapters out of the box
  • Alembic scaffold — db init-alembic for pre-wired migration setup
  • CLI commands — db 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
  • Models — Base vs Model, as_dict(), copy_with(), mixins
  • Database & Migrations — Alembic scaffold, CLI commands, env.py setup
  • Audit Trail — AuditMixin columns and automatic field population
  • Soft Delete — SoftDeleteMixin, 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

Metadata

Release files for pyramid-sa 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyramid-sa 0.9.0
File Size Uploaded
pyramid_sa-0.9.0.tar.gz 110.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyramid-sa 0.9.0
File Interpreter ABI Platform
pyramid_sa-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 126.9 kB

Release files / pyramid_sa-0.9.0.tar.gz

Download URL pyramid_sa-0.9.0.tar.gz
Size 110.4 kB
Tags Source
SHA-256 checksum
How to use checksums
56dbc5d0d2e26e389f141f8ae3fe7e44443d1bb89e8485be38213b859cae5994
BLAKE2b-256 checksum
How to use checksums
b9e2dc1e476697d14796024e5c295c2a26eef548e5efb75fe9640126aa6d6d51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.

Transparency log

Release files / pyramid_sa-0.9.0-py3-none-any.whl

Download URL pyramid_sa-0.9.0-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2f07a6d5ca06218c424487e92672951f500859bbafc377f107946a42f778d56
BLAKE2b-256 checksum
How to use checksums
2b63e8c4ef5f066fc9751c9389ded0bd54837f8ee2ace3e14889d57320525e19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page