Barograph.SQL (barograph v0.2.0)

Copy Markdown View Source

Raw SQL execution against a Barograph database.

Level 3 of the query layer (spec §9.2): always available, never second-class. Each call opens a short-lived read connection — WAL mode allows concurrent readers alongside the single writer, so reads never contend with the write path. A dedicated read pool replaces this when the Ecto integration lands.

Summary

Functions

Runs sql with positional (?1, ?2, …) parameters against the database behind db.

Functions

query(db, sql, params \\ [])

@spec query(Barograph.db(), String.t(), [term()]) ::
  {:ok, [%{required(String.t()) => term()}]} | {:error, term()}

Runs sql with positional (?1, ?2, …) parameters against the database behind db.

Returns {:ok, rows} where each row is a map of column name to value, or {:error, reason}.