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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyramid_sa-0.7.3.tar.gz
  • Upload date:
  • Size: 93.8 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.3.tar.gz
Algorithm Hash digest
SHA256 f65fafad28008034a10551425d73997a29459d2b3d5ccec047bc7ac4ff1a965b
MD5 eb0cbd59b08edfa1ffe69943b18eba0e
BLAKE2b-256 994d3f56785438a0865d51a5ca2c239d5fff5c2467f004cfd5b037a2b9ba50db

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyramid_sa-0.7.3-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.7.3-py3-none-any.whl
Algorithm Hash digest
SHA256 41ea582b2da1bac51f0ca8c43252ecad36ad9c6c3e32cbf99408161dd21cc128
MD5 107d7f129bf0bf54f2f6f687404fb663
BLAKE2b-256 1c29088332cf094294b25af305ab89d3e789ba6f3350e7b313fa45fc18b6acaa

See more details on using hashes here.

Provenance

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