summaryrefslogtreecommitdiffstats
path: root/dependencies/pkg/mod/github.com/mattn/go-sqlite3@v1.14.16/_example/vtable/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'dependencies/pkg/mod/github.com/mattn/go-sqlite3@v1.14.16/_example/vtable/main.go')
-rw-r--r--dependencies/pkg/mod/github.com/mattn/go-sqlite3@v1.14.16/_example/vtable/main.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/dependencies/pkg/mod/github.com/mattn/go-sqlite3@v1.14.16/_example/vtable/main.go b/dependencies/pkg/mod/github.com/mattn/go-sqlite3@v1.14.16/_example/vtable/main.go
new file mode 100644
index 0000000..aad8dda
--- /dev/null
+++ b/dependencies/pkg/mod/github.com/mattn/go-sqlite3@v1.14.16/_example/vtable/main.go
@@ -0,0 +1,38 @@
+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("github", &githubModule{})
+ },
+ })
+ db, err := sql.Open("sqlite3_with_extensions", ":memory:")
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer db.Close()
+
+ _, err = db.Exec("create virtual table repo using github(id, full_name, description, html_url)")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ rows, err := db.Query("select id, full_name, description, html_url from repo")
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer rows.Close()
+ for rows.Next() {
+ var id, fullName, description, htmlURL string
+ rows.Scan(&id, &fullName, &description, &htmlURL)
+ fmt.Printf("%s: %s\n\t%s\n\t%s\n\n", id, fullName, description, htmlURL)
+ }
+}