Skip to content

v0.3.0

Latest

Choose a tag to compare

@bnema bnema released this 29 Nov 15:07
v0.3.0
513e211

The sqlite package now exposes a broad safe Go API generated from sqlite3.h, including Go callbacks. The project layout is simpler, and the README is rewritten for library users.

Breaking changes

  • sqlite.Open returns *sqlite.Conn instead of the sqlite.DB interface. sqlite.DB is removed.
  • Conn.Prepare, Conn.Query and Conn.Exec return the concrete types *sqlite.Stmt, *sqlite.Rows and *sqlite.Result.
  • Mockable interfaces live in sqlite/sqliteiface. Use sqliteiface.Wrap(conn) to get a sqliteiface.DB. The mocks in sqlite/mocks use these interfaces.
  • Go 1.27 or later is required (was 1.26).

New

  • Generated safe API: Conn, Stmt, Blob, Backup, Context and Value methods with Go errors, strings, out-parameters and handle lifetimes.
  • Errors: sentinels for every primary and extended result code (ErrBusy, ErrConstraintPrimaryKey, …). They work with errors.Is and errors.As(*sqlite.Error). ErrNotAvailable is returned when the loaded SQLite lacks a function.
  • Blobs and backup: incremental blob I/O (BlobOpen, Read, Write, Reopen) and online backup (Conn.Backup, Step).
  • Operations: WALCheckpoint, WALAutoCheckpoint, LoadExtension, Limit, TxnState, status counters, and expanded and normalized SQL.
  • Go callbacks: CreateFunction, CreateAggregate, CreateCollation, ExecFunc, BusyHandler, BusyTimeout, CommitHook, RollbackHook, UpdateHook, ProgressHandler and SetAuthorizer. A panic in a callback is recovered and returned as a *sqlite.CallbackPanicError by the call that ran it.
  • OpenFlags: explicit SQLITE_OPEN_* flags and VFS selection. Open uses sqlite3_open_v2 and accepts file: URIs.

Not supported yet

  • Window functions written in Go
  • Virtual tables
  • trace_v2, wal_hook, preupdate_hook
  • Session and changeset
  • serialize / deserialize
  • UTF-16 APIs

cmd/sqlitegen/coverage_gen.tsv lists the status of every C function.

Install

go get bnema.dev/purego-sqlite@v0.3.0

Requires Linux, CGO_ENABLED=0, and libsqlite3.so or libsqlite3.so.0 at runtime.


Source of truth: https://git.bnema.dev/purego-sqlite/releases/tag/v0.3.0