A sequential connection derived from one Tursox.Database resource.
Closing the parent database safely invalidates this resource. Mutable native operations are serialized per connection; independent connections do not use a global lock.
Summary
Functions
Returns whether this connection is currently in autocommit mode.
Begins a deferred, immediate, exclusive, or MVCC concurrent transaction.
Flushes dirty connection pages to the journal.
Runs a tested WAL/MVCC checkpoint pragma.
Logically closes a connection. It is safe to call repeatedly.
Commits the active transaction.
Executes one bound SQL statement and discards execution metadata.
Executes all statements in a SQL batch without bound parameters.
Executes one bound SQL statement and returns affected-row metadata.
Returns the row ID from the most recent successful insert.
Loads a native Turso extension into this connection.
Runs a validated pragma query and returns ordered row lists.
Runs an argument-bearing pragma without interpolating caller-controlled SQL.
Updates a validated pragma and returns any ordered result rows.
Prepares a real native statement owned by this connection.
Prepares and starts a bounded native cursor convenience query.
Retries a complete transaction callback after classified conflicts.
Rolls back the active transaction.
Sets and verifies the experimental MVCC checkpoint threshold.
Returns :idle in autocommit mode and :transaction otherwise.
Runs a rollback-safe transaction callback.
Types
Functions
@spec autocommit?(t()) :: {:ok, boolean()} | {:error, Tursox.Error.t()}
Returns whether this connection is currently in autocommit mode.
Begins a deferred, immediate, exclusive, or MVCC concurrent transaction.
@spec cache_flush(t()) :: :ok | {:error, Tursox.Error.t()}
Flushes dirty connection pages to the journal.
Runs a tested WAL/MVCC checkpoint pragma.
@spec close(t()) :: :ok
Logically closes a connection. It is safe to call repeatedly.
Commits the active transaction.
@spec execute(t(), String.t(), term()) :: :ok | {:error, Tursox.Error.t()}
Executes one bound SQL statement and discards execution metadata.
@spec execute_batch(t(), String.t()) :: :ok | {:error, Tursox.Error.t()}
Executes all statements in a SQL batch without bound parameters.
@spec execute_result(t(), String.t(), term()) :: {:ok, Tursox.Result.t()} | {:error, Tursox.Error.t()}
Executes one bound SQL statement and returns affected-row metadata.
@spec last_insert_rowid(t()) :: {:ok, integer()} | {:error, Tursox.Error.t()}
Returns the row ID from the most recent successful insert.
@spec load_extension(t(), String.t()) :: :ok | {:error, Tursox.Error.t()}
Loads a native Turso extension into this connection.
The database must be opened with unsafe_features: [:runtime_extensions].
Native libraries execute arbitrary code inside the BEAM process. SQLite ABI
extensions are not automatically Turso ABI extensions.
@spec pragma_query(t(), atom() | String.t()) :: {:ok, [[term()]]} | {:error, Tursox.Error.t()}
Runs a validated pragma query and returns ordered row lists.
@spec pragma_query( t(), atom() | String.t(), {:identifier, String.t()} | non_neg_integer() | String.t() ) :: {:ok, [[term()]]} | {:error, Tursox.Error.t()}
Runs an argument-bearing pragma without interpolating caller-controlled SQL.
Use {:identifier, name} for table/index arguments. Non-negative integers
support bounded integrity checks, and strings are safely quoted for structured
engine arguments such as CDC modes.
@spec pragma_update(t(), atom() | String.t(), term()) :: {:ok, [[term()]]} | {:error, Tursox.Error.t()}
Updates a validated pragma and returns any ordered result rows.
@spec prepare(t(), String.t()) :: {:ok, Tursox.Statement.t()} | {:error, Tursox.Error.t()}
Prepares a real native statement owned by this connection.
@spec query(t(), String.t(), term()) :: {:ok, Tursox.Cursor.t()} | {:error, Tursox.Error.t()}
Prepares and starts a bounded native cursor convenience query.
Retries a complete transaction callback after classified conflicts.
Rolls back the active transaction.
Sets and verifies the experimental MVCC checkpoint threshold.
@spec status(t()) :: {:ok, :idle | :transaction} | {:error, Tursox.Error.t()}
Returns :idle in autocommit mode and :transaction otherwise.
Runs a rollback-safe transaction callback.