Database¶
transcript_indexer.db.connection
¶
Connection factory: WAL, sqlite-vec, migrations, and meta consistency.
The chunk_embeddings vec0 table is dimension-locked at create time, so it
is created here at runtime from config rather than in the migration. The
chosen dimensions/provider/model are recorded in the meta table; if config
disagrees with meta on a later open, we refuse to start and direct the user
to txi reembed --change-dimension.
count_orphaned_embeddings(conn)
¶
Count embedding vectors whose chunks row no longer exists.
Source code in src/transcript_indexer/db/connection.py
prune_orphaned_embeddings(conn)
¶
Delete embedding vectors whose chunks row no longer exists.
chunk_embeddings is a vec0 virtual table, and SQLite virtual tables
cannot participate in foreign keys, so nothing cascades into it. Vectors
orphaned by a re-sync still occupy slots in a MATCH ... AND k = ? result
set and are then dropped by the join in search_semantic, which silently
returns fewer than k hits. Returns the number of vectors deleted.
Source code in src/transcript_indexer/db/connection.py
open_connection(cfg, *, read_only=False)
¶
Open a SQLite connection with sqlite-vec loaded, WAL mode, FK enforcement, migrations applied, and chunk_embeddings ensured.
Source code in src/transcript_indexer/db/connection.py
open_for_path(db_path, dimensions=1024)
¶
Test-friendly opener: bypass Config, point at an explicit DB path.
Source code in src/transcript_indexer/db/connection.py
transcript_indexer.db.schema
¶
Migration runner. Tracks schema version via PRAGMA user_version.
migrate(conn)
¶
Apply any pending migrations. Returns the new user_version.