Skip to content

Reference#

Hand-crafted API reference covering every public export of pgdorm, pgdorm.typing, pgdorm.migrate, pgdorm.testing, and the pgdorm CLI. Signatures are checked against the source on every build, and symbol coverage is verified bidirectionally against each package's __all__.

For concepts, tutorials, and end-to-end walkthroughs, start with First Shift or The Elephant Dormitory Story.

Layered Public Packages#

Package Purpose Reference Page
pgdorm Core ORM surface: models, types, query/DML builders, expressions, runtime pool, and typed exceptions Models & Types, Queries & DML, Expressions & Functions, Runtime & Pool, Errors & Linters
pgdorm.typing Strictly typed protocols, type aliases, and helper types (zero runtime helper functions) Typing
pgdorm.migrate Online schema migrations, AST diffing, lock-timeout guards, and rollback planning Migrations
pgdorm.testing Zero-mock test helpers, PostgreSQL container factories, and schema isolation fixtures Testing
pgdorm CLI Command-line migration runner, schema inspection, and doctor diagnostics CLI

Type-Checker Guarantees#

The public API is written in modern, fully annotated Python and checked in strict mode, so standard type checkers infer precise types with no stubs or plugins.

All Table subclasses are slot-backed (__slots__, zero __dict__), query builders propagate row and column types through Select[T], Executable[RetT], and ReadQuery[RetT], and read-only pools (ReadPool / ReadTransaction) statically reject write statements at type-check time.

Machine-Readable Indexes#

Reference Pages#

  1. Models & Types — Table, TypeTable, Col, column/constraint descriptors, Registry, Create/Patch DTOs, PostgreSQL type markers, Range, JSON/FTS types, ERD export, and version helpers.
  2. Queries & DML — select, insert, insert_many, insert_subtype, update, delete, merge, RETURNING, CTEs, LATERAL joins, set operations, subqueries, compile, prepare, and ResultRow.
  3. Expressions & Functions — Expr, OrderSpec, param, lit, func, cast, case, aggregates, grouping sets, window functions & frames, full-text search, and JSONB/SQL-JSON helpers.
  4. Runtime & Pool — Pool, ReadPool, Connection, Transaction, Pipeline, RowStream, ArrowStream, SplitResult, Listener, ExplainPlan, Trace, TelemetryHook, and doctor.
  5. Errors & Linters — PgdormError hierarchy, schema/join/DML linters, and typed PostgreSQL SQLSTATE exceptions with retryability rules.
  6. Typing — Public protocols, type aliases, and generic bounds in pgdorm.typing.
  7. Migrations — pgdorm.migrate schema snapshots, diffs, operations, and online migration runner.
  8. Testing — pgdorm.testing container helpers and database fixtures.
  9. CLI — pgdorm command-line subcommands and flags.