fraudtwin.postgres#
Optional PostgreSQL persistence adapters.
Status: Optional
Classes#
Non-secret metadata recorded in a generated run manifest. |
Functions#
|
Return applied migration versions without changing the database. |
|
Fail before file emission when the operational schema is unavailable. |
|
Apply the packaged, ordered PostgreSQL migrations and return the version. |
|
Persist one generated run atomically after migrations have been applied. |
|
Persist a partition-record stream without whole-run materialization. |
Constants and protocols#
Name |
Reference |
|---|---|
|
|
|
|
Detailed API#
Optional PostgreSQL operational sink for generated FraudTwin runs.
The sink is intentionally kept behind a lazy psycopg import. File-mode
generation therefore remains dependency-free, while an enabled PostgreSQL
output receives the same observable records in one transactional write.
- class fraudtwin.postgres.PostgresPersistenceResult(schema_version, row_counts, logical_fingerprint, idempotent=False)[source][source]
Bases:
objectNon-secret metadata recorded in a generated run manifest.
- Parameters:
schema_version (str)
row_counts (dict[str, int])
logical_fingerprint (str)
idempotent (bool)
- fraudtwin.postgres.database_status(dsn=None)[source][source]
Return applied migration versions without changing the database.
- Return type:
tuple[str,...]- Parameters:
dsn (str | None)
- fraudtwin.postgres.ensure_database_ready(dsn=None)[source][source]
Fail before file emission when the operational schema is unavailable.
- Return type:
None- Parameters:
dsn (str | None)
- fraudtwin.postgres.migrate_database(dsn=None)[source][source]
Apply the packaged, ordered PostgreSQL migrations and return the version.
- Return type:
str- Parameters:
dsn (str | None)
- fraudtwin.postgres.persist_scale_records(records, run_id, *, dsn=None, batch_size=2_000)[source][source]
Persist a partition-record stream without whole-run materialization.
Scale rows are kept in a narrow staging table so chunks can be consumed independently by downstream jobs. The established
persist_runAPI remains unchanged for small, typed in-memory runs.- Return type:
- Parameters:
records (Iterable[Mapping[str, Any]])
run_id (str)
dsn (str | None)
batch_size (int)