db.connection

SQLite connection helpers for the webapp persistence layer.

This module owns connection-level concerns only: opening the SQLite database, creating parent directories, and applying connection PRAGMA defaults.

Functions

connect_database(db_path)

Open a SQLite connection configured for webapp usage.

Module Contents

db.connection.connect_database(db_path)

Open a SQLite connection configured for webapp usage.

Parameters:

db_path (pathlib.Path) – Filesystem path to the SQLite database file.

Returns:

Open sqlite3.Connection with sqlite3.Row row factory.

Return type:

sqlite3.Connection

Notes

The connection applies SQLite PRAGMAs tuned for this webapp’s read-heavy access pattern:

  • foreign_keys = ON to enforce package/table relationships.

  • journal_mode = WAL to improve concurrent read behavior.

  • synchronous = NORMAL to balance durability and write latency.

  • busy_timeout = 5000 to reduce transient lock failures.