Skip to main content

Module pool

Module pool 

Source
Expand description

Database connection setup: WAL journal mode, a busy timeout (so concurrent CLI + GUI access to the same file doesn’t immediately error out with SQLITE_BUSY), and foreign-key enforcement (off by default in SQLite, and required here since every child table relies on ON DELETE CASCADE/ON DELETE SET NULL).

Functions§

connect
Opens (creating if missing) the SQLite database at path, applies the standard pragmas, rejects incompatible migration histories, and runs pending migrations. This is the only supported way to get a SqlitePool in bhtune — every caller (CLI, web server, tests) goes through this function so the pragmas and migration state can never drift between adapters.
connect_in_memory
Opens a private, in-process database for tests: same pragmas and migrations as connect, but nothing touches disk.
connect_read_only
Opens an existing SQLite database without creating it or applying migrations.
database_path
Returns the filesystem path attached to SQLite’s main database, or DbError::DatabasePathUnavailable for private in-memory databases. Live controller mutations require this stable identity to acquire process-shared ownership. Callers canonicalize the returned path before comparing filesystem aliases.