Module layout¶
codegen_database’s public API is split into three clearly-scoped buckets. Knowing which bucket a symbol lives in tells you when to reach for it and from where to import it.
Bucket |
Import prefix |
What lives here |
|---|---|---|
Declarative primitives |
|
Base classes, column types, view/function/check/FK/index
helpers, plugin and extension base classes, and
|
Migration glue |
|
The hooks you wire into your project’s |
Pre-built features |
|
Ledgers, audit query builders, state machines, incremental
refresh, cron, row-level security, chart
helpers. Each |
Why the split¶
Primitives are the only imports you need to read a codegen_database model file and understand what is being declared.
Migration glue is code that only runs at schema-change time, inside Alembic’s context. It is isolated so that regular application code never has to pull in Alembic machinery.
Pre-built features sit on top of the primitives. Each one is opt-in: you import it only if you want the behavior. Users can write their own package under the same convention (
myproject.codegen_database_ext.X) and discover it via thecodegen_database.extentry point group (see Extension system).
Rule of thumb¶
If you are writing class MyTable(CodegenDatabaseBase), you only need
imports from codegen_database. If you are wiring env.py, you only
need imports from codegen_database.alembic. If you are reaching for a
ledger query builder or a cron job, that lives
in codegen_database.ext.<feature>.