rally_runtime/db

Values

pub fn bool_to_int(val: Bool) -> sqlight.Value

Encode a Bool as a SQLite integer value, using 1 for True and 0 for False.

pub fn get_timing() -> #(Int, Int)

Get accumulated DB timing for the current request. Returns #(total_milliseconds, query_count).

pub fn init_timing() -> Nil

Reset accumulated DB timing. Call at the start of each request/message.

pub fn nullable_text(val: option.Option(String)) -> sqlight.Value

Encode optional text as a SQLite value.

pub fn one(rows: List(a)) -> option.Option(a)

Return the only row in a result set, or None when the query returned zero rows or more than one row.

pub fn open(
  path: String,
) -> Result(sqlight.Connection, sqlight.Error)

Open a SQLite connection with Rally’s default pragmas: WAL, busy timeout, and foreign key enforcement.

pub fn query(
  sql sql: String,
  on conn: sqlight.Connection,
  with params: List(sqlight.Value),
  expecting decoder: decode.Decoder(a),
) -> Result(List(a), sqlight.Error)

Timed query wrapper. Same signature as sqlight.query but adds debug logging with query text, param count, elapsed time, and row count. Accumulates timing in the process dictionary for per-request totals.

pub fn transaction(
  conn: sqlight.Connection,
  body: fn() -> Result(a, sqlight.Error),
) -> Result(a, sqlight.Error)

Run a nested-safe SQLite transaction using SAVEPOINT.

Search Document