db.importer
Importer workflow for metadata JSON + ZIP package pairs.
Functions
|
Load metadata JSON and enforce object-root structure. |
|
Read one txt entry and return |
|
Import one metadata+zip pair and create one SQLite table per |
Module Contents
- db.importer.load_metadata_json(metadata_path)
Load metadata JSON and enforce object-root structure.
- Parameters:
metadata_path (pathlib.Path) – Path to metadata JSON file.
- Returns:
Parsed JSON object.
- Raises:
ValueError – If the root JSON value is not an object.
- Return type:
- db.importer.read_txt_rows(archive, entry_name)
Read one txt entry and return
(line_number, value)tuples.Empty and whitespace-only lines are skipped during import so DB tables only store meaningful values.
- db.importer.import_package_pair(conn, *, metadata_path, zip_path)
Import one metadata+zip pair and create one SQLite table per
*.txt.The importer ignores JSON files inside the archive. It uses metadata
files_included(when provided) to limit which*.txtentries are imported.- Parameters:
conn (sqlite3.Connection) – Open SQLite connection.
metadata_path (pathlib.Path) – Path to
*_metadata.jsonfile.zip_path (pathlib.Path) – Path to package zip file.
- Returns:
API-style summary payload describing imported package and created tables.
- Raises:
FileNotFoundError – If metadata or zip path does not exist.
ValueError – For invalid metadata, duplicate imports, or zip format/data issues.
- Return type: