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>
38 lines
789 B
Go
38 lines
789 B
Go
package fts5_test
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
|
|
"github.com/hanzoai/sqlite3/driver"
|
|
"github.com/hanzoai/sqlite3/ext/fts5"
|
|
_ "github.com/hanzoai/sqlite3/vfs/memdb"
|
|
)
|
|
|
|
func Example() {
|
|
db, err := driver.Open("file:/test.db?vfs=memdb", fts5.Register)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer db.Close()
|
|
|
|
_, err = db.Exec(`
|
|
CREATE VIRTUAL TABLE docs USING fts5(title, body);
|
|
INSERT INTO docs(title, body) VALUES
|
|
('Go Programming', 'An intensive guide to Go routines.'),
|
|
('SQLite Tutorial', 'Learn how to use virtual tables efficiently.');
|
|
`)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
var title string
|
|
err = db.QueryRow("SELECT title FROM docs WHERE docs MATCH 'Go AND routines'").Scan(&title)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
fmt.Println(title)
|
|
// Output: Go Programming
|
|
}
|