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
This commit is contained in:
Patrick DeVivo
2020-12-26 09:11:17 -05:00
committed by GitHub
parent 66ff625f34
commit 92d23714a8
4 changed files with 325 additions and 3 deletions

View File

@@ -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)
}
}