SQLAlchemy 2.0 Textbook Ch. 12 — Production Patterns

Production SQLAlchemy: pool sizing with PgBouncer, read replica routing, OTEL instrumentation, multi-tenancy with RLS, and graceful failure modes.

May 7, 2026 · 4 min · 760 words · Manvendra Rajpoot

SQLAlchemy + Postgres Cheatsheet 13 — DB-Per-Tenant

Cheatsheet: per-tenant engine cache, connection routing, multi-DB Alembic, onboarding.

May 13, 2026 · 3 min · 487 words · Manvendra Rajpoot

SQLAlchemy Cheatsheet 13 — Soft Delete, Audit, and Timestamps

Cheatsheet: SoftDeleteMixin, auto-timestamps via events, audit log table, with_loader_criteria for transparent filtering.

May 12, 2026 · 3 min · 576 words · Manvendra Rajpoot

SQLAlchemy + Postgres Cheatsheet 14 — pgvector for Embeddings

Cheatsheet: Vector column, cosine_distance / l2 / inner_product, HNSW index, hybrid filter + ANN.

May 13, 2026 · 3 min · 476 words · Manvendra Rajpoot

SQLAlchemy Cheatsheet 14 — Multi-Tenancy Patterns

Cheatsheet: shared DB + tenant_id, schema-per-tenant, DB-per-tenant, query filters, context propagation.

May 12, 2026 · 3 min · 481 words · Manvendra Rajpoot

SQLAlchemy + Postgres Cheatsheet 15 — Replication, Read Replicas, and Failover

Cheatsheet: writer/reader engines, target_session_attrs, read-after-write, replica lag awareness.

May 13, 2026 · 3 min · 484 words · Manvendra Rajpoot

SQLAlchemy Cheatsheet 15 — Common Pitfalls and Fixes

Cheatsheet: N+1, IntegrityError, DetachedInstanceError, MissingGreenlet, lazy-load in async, pool exhaustion.

May 12, 2026 · 3 min · 610 words · Manvendra Rajpoot

SQLAlchemy Cheatsheet 16 — Type Annotations and Mapped Style

Cheatsheet: Mapped types, mapped_column with types, type_annotation_map, Annotated types, generic mapping.

May 12, 2026 · 3 min · 592 words · Manvendra Rajpoot

SQLAlchemy Cheatsheet 17 — Inheritance and Polymorphism

Cheatsheet: single-table inheritance, joined-table inheritance, concrete inheritance, polymorphic loading, with_polymorphic.

May 12, 2026 · 3 min · 577 words · Manvendra Rajpoot

SQLAlchemy Cheatsheet 18 — Hybrid Properties, Computed Columns, and Aggregates

Cheatsheet: when to use hybrid_property vs column_property vs Computed, with FastAPI integration.

May 12, 2026 · 3 min · 526 words · Manvendra Rajpoot