db.repositories =============== .. py:module:: db.repositories .. autoapi-nested-parse:: 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 --------- .. autoapisummary:: db.repositories.slugify_identifier db.repositories.build_package_table_name db.repositories.list_packages db.repositories.list_package_tables db.repositories.delete_package db.repositories.get_package_table Module Contents --------------- .. py:function:: slugify_identifier(value, max_length) Convert free text into an ASCII-safe SQL identifier chunk. .. py:function:: build_package_table_name(package_name, txt_stem, package_id, index) Create a safe SQLite table name that references package and txt source. .. py:function:: list_packages(conn) Return imported package list for the Database View tab. .. py:function:: list_package_tables(conn, package_id) Return txt tables for one package id. .. py:function:: 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. :param conn: Open SQLite connection. :param package_id: Package id to delete. :returns: Summary dict with deleted package name and table count. :raises ValueError: If the package id does not exist. .. py:function:: get_package_table(conn, table_id) Return one package table metadata row by id.