Documentation
¶
Overview ¶
Package blobio provides an SQL interface to incremental BLOB I/O.
Example ¶
// Open the database, registering the extension. db, err := driver.Open("file:/test.db?vfs=memdb", blobio.Register) if err != nil { log.Fatal(err) } defer db.Close() _, err = db.Exec(`CREATE TABLE test (col)`) if err != nil { log.Fatal(err) } const message = "Hello BLOB!" // Create the BLOB. r, err := db.Exec(`INSERT INTO test VALUES (?)`, sqlite3.ZeroBlob(len(message))) if err != nil { log.Fatal(err) } id, err := r.LastInsertId() if err != nil { log.Fatal(err) } // Write the BLOB. _, err = db.Exec(`SELECT writeblob('main', 'test', 'col', ?, 0, ?)`, id, message) if err != nil { log.Fatal(err) } // Read the BLOB. _, err = db.Exec(`SELECT readblob('main', 'test', 'col', ?, 0, ?)`, id, sqlite3.Pointer(os.Stdout)) if err != nil { log.Fatal(err) }
Output: Hello BLOB!
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(db *sqlite3.Conn) error
Register registers the SQL functions:
readblob(schema, table, column, rowid, offset, n/writer)
Reads n bytes of a blob, starting at offset.
writeblob(schema, table, column, rowid, offset, data/reader)
Writes data into a blob, at the given offset.
openblob(schema, table, column, rowid, write, callback, args...)
Opens blobs for reading or writing. The callback is invoked for each open blob, and must be bound to an OpenCallback, using sqlite3.BindPointer or sqlite3.Pointer. The optional args will be passed to the callback, along with the sqlite3.Blob handle. The sqlite3.Blob handle is only valid during the execution of the callback. Callers cannot read or write to the handle after the callback exits.
Types ¶
type OpenCallback ¶
type OpenCallback func(*sqlite3.Blob, ...sqlite3.Value) error
OpenCallback is the type for the openblob callback.
Click to show internal directories.
Click to hide internal directories.