driver

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package driver provides a lightweight database/sql driver for tinySQL.

The driver exposes tinySQL through the standard `database/sql` API and supports both in-memory and file-backed databases. Key features:

  • DSN formats: `mem://` and `file:/path/to/db.gob?options` (see `parseDSN`).
  • Optional Write-Ahead Log (WAL) and autosave for durability.
  • `mode=` selects any storage.StorageMode (disk, json, hybrid, wal, ...) via storage.OpenDB instead of the default GOB-snapshot behavior.
  • Reader/writer pools and simple MVCC-style snapshots for transactions.
  • Simple, safe placeholder binding: sequential `?` and numbered `$1`/`:1`.

Use `sql.Open("tinysql", dsn)` to create a connection. See `applyDSNOption` and `applyQueryOptions` for available DSN options and defaults.

Index

Constants

This section is empty.

Variables

View Source
var ErrTransactionConflict = errors.New("tinysql: transaction conflict")

ErrTransactionConflict reports that a transaction attempted to commit a table that was changed after its snapshot was taken. Callers can use errors.Is to distinguish a retryable write conflict from other failures.

Functions

func CurrentDefaultDB added in v0.11.0

func CurrentDefaultDB() *storage.DB

CurrentDefaultDB returns the storage database currently backing the default driver server, if one exists.

func OpenInMemory added in v0.5.1

func OpenInMemory(tenant string) (*sql.DB, error)

OpenInMemory returns a *sql.DB backed by an in-memory tinySQL server. If tenant is empty the default tenant is used.

func SetDefaultDB

func SetDefaultDB(db *storage.DB)

SetDefaultDB allows external code to provide a storage.DB instance that will be used by the driver when opening connections. This is useful for embedding environments (WASM) that want to keep a reference to the underlying DB.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL