sqlite_wasm

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package sqlite_wasm implements a database/sql driver for sqlite.wasm via starpc RPC to a dedicated Worker running sqlite.wasm with OPFS persistence. Registers as "sqlite3-wasm" with database/sql.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteDatabase

func DeleteDatabase(path string) error

DeleteDatabase deletes a database by path via the RPC client.

func NewStore

func NewStore(db *sql.DB, table string) (*common.Store[SqliteWasmBridgeConfig], error)

NewStore constructs a new key-value store from a sqlite-wasm database.

func Open

Open opens a sqlite-wasm database and wraps it in a kvtx store.

func OpenWithMode

func OpenWithMode(ctx context.Context, path string, mode os.FileMode, table string) (*common.Store[SqliteWasmBridgeConfig], error)

OpenWithMode opens a sqlite-wasm database with mode and wraps it in a kvtx store.

func OpenWithPragmas added in v0.51.0

func OpenWithPragmas(ctx context.Context, path string, table string, pragmas common.Pragmas) (*common.Store[SqliteWasmBridgeConfig], error)

OpenWithPragmas opens a sqlite-wasm database and applies the supplied tunable pragmas.

func SetClient

func SetClient(client sql_sqlite_wasm_rpc.SRPCSqliteBridgeClient)

SetClient sets the RPC client used by the driver. Call with nil to clear the client (e.g. on Worker disconnect).

Types

type SqliteWasmBridgeConfig

type SqliteWasmBridgeConfig struct{}

SqliteWasmBridgeConfig implements common.SQLiteDriverConfig for the sqlite-wasm RPC-based driver.

func (SqliteWasmBridgeConfig) ConfigureDBPool

func (c SqliteWasmBridgeConfig) ConfigureDBPool(db *sql.DB)

ConfigureDBPool constrains database/sql to a single underlying connection. The sqlite-wasm bridge models one physical sqlite database per path inside the Worker, so allowing database/sql to fan out would create duplicate physical opens for the same OPFS-backed file.

func (SqliteWasmBridgeConfig) Description

func (c SqliteWasmBridgeConfig) Description() string

Description returns a human-readable description.

func (SqliteWasmBridgeConfig) DriverName

func (c SqliteWasmBridgeConfig) DriverName() string

DriverName returns the driver name for sql.Open().

func (SqliteWasmBridgeConfig) IsBusyError

func (c SqliteWasmBridgeConfig) IsBusyError(err error) bool

IsBusyError checks if the error is a SQLITE_BUSY error.

func (SqliteWasmBridgeConfig) IsNestedTxError

func (c SqliteWasmBridgeConfig) IsNestedTxError(err error) bool

IsNestedTxError checks if the error is a nested transaction error.

func (SqliteWasmBridgeConfig) OpenDSN

func (c SqliteWasmBridgeConfig) OpenDSN(path string) string

OpenDSN returns the DSN for sql.Open() for a given database path.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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