httk.store.backend.sql.layout¶
Versioned physical layout for httk.store.backend.sql.store.SqlStore.
Attributes¶
The persisted SqlStore layout protocol implemented by this package. |
|
Reserved key/value table holding the store protocol and entry declaration. |
|
Exceptions¶
A database does not exactly implement the current persisted store layout. |
|
A new open found an interrupted empty-store bulk ingest. |
Classes¶
One immutable configured entry family and its concrete records. |
|
The immutable normalized entry declaration of an initialized store. |
|
Dialect capabilities used by the SQL storage protocol. |
Functions¶
|
Serialize a normalized declaration in its exact deterministic persisted form. |
|
Resolve the hardcoded protocol facts for one supported dialect. |
|
Normalize a declaration and apply SQL physical-name validation. |
|
Normalize application-owned declarations and apply SQL physical-name validation. |
|
Merge registered and application-owned declarations and validate SQL names. |
|
Return SQLAlchemy metadata for all protocol-owned tables of |
|
Return the reserved protocol key/value table in |
|
Return application schema-object names mapped to their stable object kinds. |
|
Return application base-table names without SQLAlchemy reflection. |
|
Return the physical column names of |
|
Read the marker values, or return |
Module Contents¶
- class httk.store.backend.sql.layout.EntryFamilyLayout[source]¶
One immutable configured entry family and its concrete records.
- class httk.store.backend.sql.layout.StorageLayout[source]¶
The immutable normalized entry declaration of an initialized store.
- families: tuple[EntryFamilyLayout, ...]¶
- property entry_records: collections.abc.Mapping[type, tuple[type, ...]]¶
Configured family classes mapped to their ordered concrete record classes.
- property declaration: collections.abc.Mapping[str, tuple[str, ...]]¶
Configured stable family names mapped to their ordered stable record names.
- exception httk.store.backend.sql.layout.StorageLayoutUpgradeRequiredError(diff, *, hint=None)[source]¶
Bases:
RuntimeErrorA database does not exactly implement the current persisted store layout.
diffis immutable and JSON-shaped. Its top-level keys are stable categories (currentlyprotocol,declarationandschema), so a caller can present a precise upgrade diagnostic without parsing the human-readable exception message. Thedeclarationcategory maps named aspect keys (metadata_keys,store_timestamps,write_profile,entry_declaration) to their own diagnostics, so several independent declaration mismatches are reported together; the exception message names the mismatched aspects.- Parameters:
diff (collections.abc.Mapping[str, object]) – The immutable JSON-shaped category-keyed difference.
hint (str | None) – An optional remediation appended to the message and exposed as
hint(e.g. that a purely additive schema change can be applied withupgrade=True).
- diff: collections.abc.Mapping[str, object]¶
- httk.store.backend.sql.layout.declaration_json(layout)[source]¶
Serialize a normalized declaration in its exact deterministic persisted form.
- httk.store.backend.sql.layout.STORAGE_PROTOCOL_VERSION: Final = '2'[source]¶
The persisted SqlStore layout protocol implemented by this package.
- httk.store.backend.sql.layout.METADATA_TABLE_NAME: Final = '_httk_store_metadata'[source]¶
Reserved key/value table holding the store protocol and entry declaration.
- exception httk.store.backend.sql.layout.StoreUnderConstructionError[source]¶
Bases:
RuntimeErrorA new open found an interrupted empty-store bulk ingest.
Crash window for new SQLite/DuckDB opens: before the marker commits the old clean state remains accepted; after the marker and through ingest, finalize, or before marker clear the store is rejected; after clear it is accepted again. The marker is intentionally not a resume protocol.
ClickHouse marker residue is fail-closed: the default recovery is to drop the database and re-ingest. Clearing the marker is valid only after an operator has restored and verified the declared empty-store invariant.
- class httk.store.backend.sql.layout.BackendFacts[source]¶
Dialect capabilities used by the SQL storage protocol.
- httk.store.backend.sql.layout.backend_facts_for_dialect(dialect_name)[source]¶
Resolve the hardcoded protocol facts for one supported dialect.
- httk.store.backend.sql.layout.normalize_entry_records(entry_records)[source]¶
Normalize a declaration and apply SQL physical-name validation.
- httk.store.backend.sql.layout.normalize_entry_families(entry_families)[source]¶
Normalize application-owned declarations and apply SQL physical-name validation.
- httk.store.backend.sql.layout.normalize_entry_declaration(entry_records, entry_families)[source]¶
Merge registered and application-owned declarations and validate SQL names.
- httk.store.backend.sql.layout.expected_metadata(layout, *, store_timestamps=True)[source]¶
Return SQLAlchemy metadata for all protocol-owned tables of
layout.
- httk.store.backend.sql.layout.metadata_table_for(metadata)[source]¶
Return the reserved protocol key/value table in
metadata.
- httk.store.backend.sql.layout.actual_schema_objects(connection)[source]¶
Return application schema-object names mapped to their stable object kinds.
The DuckDB SQLAlchemy inspector presently routes column inspection through a PostgreSQL catalogue relation DuckDB does not expose, so the whole layout path intentionally uses the dialect catalogues directly.
- httk.store.backend.sql.layout.actual_table_names(connection)[source]¶
Return application base-table names without SQLAlchemy reflection.
- httk.store.backend.sql.layout.actual_columns(connection, table_name)[source]¶
Return the physical column names of
table_namewithout SQLAlchemy reflection.The DuckDB SQLAlchemy inspector routes column inspection through a PostgreSQL catalogue relation DuckDB does not expose (see
actual_schema_objects()), so this reads the dialect catalogues directly.