Skip to content

blobio

Package blobio exposes SQLite’s incremental BLOB I/O API as SQL scalar functions, so callers can stream parts of large BLOBs from SQL without materializing the whole row into memory.

  • readblob(schema, table, column, rowid, offset, n) → BLOB Reads n bytes of the value at (schema, table, column, rowid) starting at offset. Returns the bytes as a BLOB. Reading past the value end errors.

  • writeblob(schema, table, column, rowid, offset, data) → INTEGER Writes data into the value at (schema, table, column, rowid) starting at offset. Returns the number of bytes written. The target value must be sized to hold the write (use INSERT … VALUES (zeroblob(N)) to pre-size). Writes past the value end error.

  • openblob(schema, table, column, rowid, write, callback, args…) → INTEGER Opens a handle at (schema, table, column, rowid) and invokes callback with it plus any trailing args. The callback must be bound via sqlite.Pointer as an OpenCallback; the handle is valid only for the duration of the call.

readblob and writeblob open a fresh gosqlite.org.Blob handle on every invocation; for hot loops, prefer calling gosqlite.org.Conn.OpenBlob from Go and holding the handle across reads/writes.

Ported from ncruces/ext/blobio.


Full API: pkg.go.dev/gosqlite.org/ext/blobio