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 ¶
- func DeleteDatabase(path string) error
- func NewStore(db *sql.DB, table string) (*common.Store[SqliteWasmBridgeConfig], error)
- func Open(ctx context.Context, path string, table string) (*common.Store[SqliteWasmBridgeConfig], error)
- func OpenWithMode(ctx context.Context, path string, mode os.FileMode, table string) (*common.Store[SqliteWasmBridgeConfig], error)
- func SetClient(client sql_sqlite_wasm_rpc.SRPCSqliteBridgeClient)
- type SqliteWasmBridgeConfig
- func (c SqliteWasmBridgeConfig) ConfigureDBPool(db *sql.DB)
- func (c SqliteWasmBridgeConfig) Description() string
- func (c SqliteWasmBridgeConfig) DriverName() string
- func (c SqliteWasmBridgeConfig) IsBusyError(err error) bool
- func (c SqliteWasmBridgeConfig) IsNestedTxError(err error) bool
- func (c SqliteWasmBridgeConfig) OpenDSN(path string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteDatabase ¶
DeleteDatabase deletes a database by path via the RPC client.
func Open ¶
func Open(ctx context.Context, path string, table string) (*common.Store[SqliteWasmBridgeConfig], error)
Open opens a sqlite-wasm database and wraps it in a kvtx store.
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.