Tursox.Database (tursox v0.1.0)

Copy Markdown View Source

Opaque root resource for one local embedded Turso database.

A database is opened once and can derive many independent Tursox.Connection resources. :memory databases are shared by connections derived from the same handle; separate opens remain isolated.

Builder features are experimental upstream and opt-in through :features.

Summary

Functions

Builder feature names confirmed on the pinned Turso crate.

Logically closes a database. It is safe to call repeatedly.

Derives an independent connection from this database handle.

Returns safe metadata without exposing the native reference.

Opens a local file or isolated in-memory database.

Types

t()

@opaque t()

Functions

builder_features()

@spec builder_features() :: [atom()]

Builder feature names confirmed on the pinned Turso crate.

close(database)

@spec close(t()) :: :ok

Logically closes a database. It is safe to call repeatedly.

connect(database, opts \\ [])

@spec connect(
  t(),
  keyword()
) :: {:ok, Tursox.Connection.t()} | {:error, Tursox.Error.t()}

Derives an independent connection from this database handle.

metadata(database)

@spec metadata(t()) :: map()

Returns safe metadata without exposing the native reference.

open(path, opts \\ [])

@spec open(
  :memory | String.t(),
  keyword()
) :: {:ok, t()} | {:error, Tursox.Error.t()}

Opens a local file or isolated in-memory database.

Supported options are:

  • :journal_mode:wal (default) or experimental :mvcc;
  • :features — an opt-in list from builder_features/0;
  • :create_parent — create a missing file parent directory (default false);
  • :mode — only :read_write_create is supported by Turso 0.7.2;
  • :busy_timeout — timeout used while applying/verifying open pragmas.