# `TimelessMetrics.DB`
[🔗](https://github.com/awksedgreep/timeless_metrics/blob/main/lib/timeless_metrics/db.ex#L1)

SQLite connection manager with a single writer and pooled readers.

Uses WAL mode for concurrent reads during writes. The writer is serialized
through a GenServer to respect SQLite's single-writer constraint.

# `query_result`

```elixir
@type query_result() :: {:ok, [row()]} | {:error, term()}
```

# `row`

```elixir
@type row() :: [term()]
```

# `server`

```elixir
@type server() :: GenServer.server()
```

# `backup`

```elixir
@spec backup(server(), Path.t()) :: query_result()
```

Create a consistent backup of this database using VACUUM INTO.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `db_path`

```elixir
@spec db_path(server()) :: String.t() | {:error, term()}
```

Get the database path.

# `read`

```elixir
@spec read(server(), String.t(), list()) :: query_result()
```

Execute a read query using a reader connection from the pool.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

# `write`

```elixir
@spec write(server(), String.t(), list()) :: query_result()
```

Execute a write query (INSERT, UPDATE, DELETE) through the serialized writer.

# `write_transaction`

```elixir
@spec write_transaction(server(), (term() -&gt; result)) ::
  {:ok, result} | {:error, term()}
when result: term()
```

Execute multiple write queries in a single transaction.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
