Files
sqlite3/example_test.go
hanzo-devandClaude Opus 4.8 764539773a feat: canonical Hanzo SQLite — rename module + native encrypted hanzovfs
Fork of ncruces/go-sqlite3 (MIT, retained). Renames module to
github.com/hanzoai/sqlite3 (wasm blob stays upstream ncruces/go-sqlite3-wasm)
and adds the hanzovfs package: a pure-Go, no-FUSE SQLite VFS that seals pages
with ChaCha20-Poly1305 (per-tenant DEK, HIP-0302) for per-tenant SQLite ⇒
hanzoai/vfs ⇒ S3.

Deprecates modernc.org/sqlite (no custom-VFS hook) and direct ncruces use.
Benchmarked 3.6x faster writes / ~92x faster point-reads than FUSE; encryption ~free.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 20:32:43 +00:00

55 lines
836 B
Go

package sqlite3_test
import (
"fmt"
"log"
"github.com/hanzoai/sqlite3"
)
const memory = ":memory:"
func Example() {
db, err := sqlite3.Open(memory)
if err != nil {
log.Fatal(err)
}
err = db.Exec(`CREATE TABLE users (id INT, name VARCHAR(10))`)
if err != nil {
log.Fatal(err)
}
err = db.Exec(`INSERT INTO users (id, name) VALUES (0, 'go'), (1, 'zig'), (2, 'whatever')`)
if err != nil {
log.Fatal(err)
}
stmt, _, err := db.Prepare(`SELECT id, name FROM users`)
if err != nil {
log.Fatal(err)
}
defer stmt.Close()
for stmt.Step() {
fmt.Println(stmt.ColumnInt(0), stmt.ColumnText(1))
}
if err := stmt.Err(); err != nil {
log.Fatal(err)
}
err = stmt.Close()
if err != nil {
log.Fatal(err)
}
err = db.Close()
if err != nil {
log.Fatal(err)
}
// Output:
// 0 go
// 1 zig
// 2 whatever
}