pyramid-sa
Pyramid SQLAlchemy Integration — a reusable library that wires SQLAlchemy into any Pyramid application via config.include("pyramid_sa").
Features
- Session management — engine creation, transaction-managed sessions via pyramid_tm + zope.sqlalchemy,
request.dbsessionas a reified property - Declarative base —
Basewith consistent naming conventions and utility methods (as_dict,copy_with) on every model - Audit trail — opt-in
AuditMixinthat trackscreated_at,updated_at,created_by,updated_by,created_ip,updated_ip - Soft delete — opt-in
SoftDeleteMixinwith automatic query filtering, delete interception, partial unique indexes, and safe restore - Error mapping — exception tween that translates
NoResultFoundto 404 andIntegrityErrorto 409, with customizable error bodies - JSON rendering — adapters for
datetime,date, andUUIDout of the box - Alembic scaffold —
db init-alembiccommand copies pre-wired templates into your project - CLI commands —
db dropanddb initializefor schema management - Test fixtures — companion
pyramid-sa-testingpackage with a pytest plugin for PostgreSQL-backed test sessions
Quick install
pip install pyramid-sa
For test fixtures (dev only):
pip install pyramid-sa-testing
Where to go next
- Getting Started — installation, app factory, first model
- Base & Models —
Base,Model,ORMClassutilities - Audit Trail — automatic created/updated tracking
- Soft Delete — soft-delete behavior, unique indexes, restore
- Error Handling — exception tween and custom formatters
- Database & Migrations — Alembic scaffold and CLI commands
- Testing — pytest fixtures for database testing
- API Reference — complete public API