Skip to main content

Module db

Module db 

Source
Expand description

Database access layer.

Provides connection pool initialization, migration execution, and query helpers for the three supported backends: SQLite, PostgreSQL, and MariaDB.

The shared connection pool type Db is a runtime-dispatch AnyPool that routes queries to the configured backend. All write transactions on SQLite should go through begin_write rather than pool.begin() to avoid SQLITE_BUSY_SNAPSHOT in WAL mode.

Modules§

schema
Embedded database migrations and schema version tracking.

Enums§

DbKind
Which database backend is active.

Functions§

begin_write
Begin a write transaction.
init_pool
Initialize the primary (read-write) database connection pool.
init_ro_pool
Initialize a read-only connection pool for GET handlers.
run_migrations
Run pending database migrations.

Type Aliases§

Db
Type alias for the shared connection pool (runtime-dispatch Any backend).