From 92d23714a87355a0b7087795126bc0e0e2b06098 Mon Sep 17 00:00:00 2001 From: Patrick DeVivo Date: Sat, 26 Dec 2020 09:11:17 -0500 Subject: add support for defining an "eponymous only" virtual table (#885) * add support for defining an "eponymous only" virtual table As suggested here: https://github.com/mattn/go-sqlite3/issues/846#issuecomment-736206222 * add an example of an eponymous only vtab module * add a test case for an eponymous only vtab module --- _example/vtable_eponymous_only/main.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 _example/vtable_eponymous_only/main.go (limited to '_example/vtable_eponymous_only/main.go') diff --git a/_example/vtable_eponymous_only/main.go b/_example/vtable_eponymous_only/main.go new file mode 100644 index 0000000..17b58af --- /dev/null +++ b/_example/vtable_eponymous_only/main.go @@ -0,0 +1,33 @@ +package main + +import ( + "database/sql" + "fmt" + "log" + + "github.com/mattn/go-sqlite3" +) + +func main() { + sql.Register("sqlite3_with_extensions", &sqlite3.SQLiteDriver{ + ConnectHook: func(conn *sqlite3.SQLiteConn) error { + return conn.CreateModule("series", &seriesModule{}) + }, + }) + db, err := sql.Open("sqlite3_with_extensions", ":memory:") + if err != nil { + log.Fatal(err) + } + defer db.Close() + + rows, err := db.Query("select * from series") + if err != nil { + log.Fatal(err) + } + defer rows.Close() + for rows.Next() { + var value int + rows.Scan(&value) + fmt.Printf("value: %d\n", value) + } +} -- cgit v1.2.3