Module trase.tools.data_release_package.snapshot.destination
Names and prepares the PostgreSQL schema a data release package is snapshotted into.
Every package is snapshotted into a schema of its own, named after the package folder. A snapshot is a replacement, not a merge: a package owns its schema outright, so anything already in there is dropped before the new tables are written. Since the whole snapshot runs in one transaction, a failure part-way through leaves the previous snapshot's schema untouched.
Functions
def check_identifier(identifier: str) ‑> str-
Guards the identifiers we interpolate into SQL. Raises if one looks unsafe.
def create_schema(connection, schema: str) ‑> None-
Creates
schema, owned by the role that also owns the snapshotted tables. def drop_all_tables(connection, schema: str) ‑> List[str]-
Drops every table in
schemaand returns their names. def existing_tables(connection, schema: str) ‑> List[str]-
The tables currently in
schema, including any archived by an earlier run. def prepare_schema(connection, schema: str) ‑> None-
Makes
schemaexist and be empty, ready for the package to be written into. def schema_exists(connection, schema: str) ‑> booldef schema_name(package_dir: pathlib.Path) ‑> str-
The PostgreSQL schema a package is snapshotted into, derived from its folder.