db.table_store

Low-level helpers for dynamic imported text tables.

Each imported *.txt file gets mapped to one physical SQLite table. This module owns identifier safety and row-level table operations.

Functions

quote_identifier(identifier)

Validate and quote a SQLite identifier.

create_text_table(conn, table_name)

Create one physical text table for imported txt rows.

insert_text_rows(conn, table_name, rows)

Insert parsed txt rows into a physical text table.

fetch_text_rows(conn, table_name, *, offset, limit)

Fetch paginated rows from one physical txt table.

Module Contents

db.table_store.quote_identifier(identifier)

Validate and quote a SQLite identifier.

Parameters:

identifier (str) – Unquoted table or column identifier.

Returns:

Quoted identifier safe for SQL string interpolation.

Raises:

ValueError – If identifier contains unsafe characters.

Return type:

str

db.table_store.create_text_table(conn, table_name)

Create one physical text table for imported txt rows.

The table schema is intentionally minimal:

  • id: surrogate primary key

  • line_number: source txt line number

  • value: trimmed non-empty line value

db.table_store.insert_text_rows(conn, table_name, rows)

Insert parsed txt rows into a physical text table.

db.table_store.fetch_text_rows(conn, table_name, *, offset, limit)

Fetch paginated rows from one physical txt table.

Parameters:
  • conn (sqlite3.Connection) – Open SQLite connection.

  • table_name (str) – Validated physical table name.

  • offset (int) – Zero-based row offset.

  • limit (int) – Maximum rows to return.

Returns:

List of {"line_number": int, "value": str} mappings.

Return type:

list[dict[str, Any]]