Expand description
bhtune-db — persistence.
A single, plain, open SQLite database (via sqlx, WAL mode + busy timeout + foreign keys
enforced) holds everything: DCS/PLC templates, loop configuration, and tune run history.
There is deliberately no encryption and no licensing/usage-gating table — see AGENTS.md
for why.
pool— opens the database and runs migrations (connect/connect_in_memory). The only supported way to get aSqlitePoolin bhtune.convert— mapsbhtune-core’sserde-tagged enums to/from theTEXTcolumns SQLite stores them as.models— typed row/repository APIs for every table created by the migration set.seed— upserts the built-in DCS/PLC templates on startup.backup— full-database export (VACUUM INTO) and restore, independent of any single table.error— the crate’s error type,error::DbError.
Tables: dcs_templates, loops, tune_runs, tune_samples, tune_results,
tune_mv_actuations, tune_writes, settings — see the migration files for the full
schema and the rationale behind each design decision (nullability, JSON-vs-columns,
cascade rules).
Re-exports§
pub use backup::RestoreOutcome;pub use backup::backup_to;pub use backup::restore_from;pub use error::DbError;pub use error::DbResult;pub use models::DemoSessionRow;pub use pool::connect;pub use pool::connect_in_memory;pub use seed::SeedOutcome;pub use seed::SeedResult;pub use seed::seed_builtin_templates;pub use seed::seed_templates;
Modules§
- backup
- Full-database backup and restore: a single portable SQLite file out, and back in.
- convert
- Converts
bhtune-core’sserde-tagged enums to/from the plain TEXT values SQLite stores them as. - error
bhtune-db’s error type.- models
- Row types mirroring the tables in
migrations/0001_initial_schema.sql. - pool
- 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 onON DELETE CASCADE/ON DELETE SET NULL). - seed
- Seeds a catalog of DCS/PLC templates into
dcs_templateson startup, so a fresh database always has the built-in presets available without a separate “first run” wizard step, and so a future user-supplied catalog file can be kept in sync the same way.
Type Aliases§
- Sqlite
Pool - An alias for [
Pool][crate::pool::Pool], specialized for SQLite.