db.repositories

Repository helpers for webapp metadata tables.

This module owns CRUD-style access for imported_packages and package_tables rows plus naming helpers used while importing txt files.

Functions

slugify_identifier(value, max_length)

Convert free text into an ASCII-safe SQL identifier chunk.

build_package_table_name(package_name, txt_stem, ...)

Create a safe SQLite table name that references package and txt source.

list_packages(conn)

Return imported package list for the Database View tab.

list_package_tables(conn, package_id)

Return txt tables for one package id.

delete_package(conn, package_id)

Delete one imported package and its associated dynamic txt tables.

get_package_table(conn, table_id)

Return one package table metadata row by id.

Module Contents

db.repositories.slugify_identifier(value, max_length)

Convert free text into an ASCII-safe SQL identifier chunk.

db.repositories.build_package_table_name(package_name, txt_stem, package_id, index)

Create a safe SQLite table name that references package and txt source.

db.repositories.list_packages(conn)

Return imported package list for the Database View tab.

db.repositories.list_package_tables(conn, package_id)

Return txt tables for one package id.

db.repositories.delete_package(conn, package_id)

Delete one imported package and its associated dynamic txt tables.

Drops the physical SQLite tables created during import, removes the package_tables rows (via ON DELETE CASCADE), and finally removes the imported_packages row.

Parameters:
Returns:

Summary dict with deleted package name and table count.

Raises:

ValueError – If the package id does not exist.

Return type:

dict[str, Any]

db.repositories.get_package_table(conn, table_id)

Return one package table metadata row by id.