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.8.0.tar.gz (108.1 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.8.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyramid_sa-0.8.0.tar.gz
  • Upload date:
  • Size: 108.1 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.8.0.tar.gz
Algorithm Hash digest
SHA256 c00e7192c50e01b60ff2c4163abf2f87fc80df37bbdbe2e7bc43aed843c19b78
MD5 5a43a37bb1af8d4c37e146f2c4b26c3a
BLAKE2b-256 fcefcd2a4e3b1c7b7047fc1990380bb7027ee1a3fa64a769a02c55b1bf935b2e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyramid_sa-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 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.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e6b9a9d883a956b9fc1f3361f8c6dad305d0024f869f33af8a8463307e80808
MD5 5e527574c5f1f9d097d22254f47f3fc7
BLAKE2b-256 2a9d17891ba7571542b6f7812f72fa1324c613a4cb80c2a75da3a3330e94b400

See more details on using hashes here.

Provenance

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