File: extension.go

package info (click to toggle)
golang-github-mattn-go-sqlite3 1.6.0~ds1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, buster-backports, experimental
  • size: 448 kB
  • sloc: cpp: 1,132; ansic: 537; makefile: 41
file content (37 lines) | stat: -rw-r--r-- 773 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main

import (
	"database/sql"
	"fmt"
	"log"

	"github.com/mattn/go-sqlite3"
)

func main() {
	sql.Register("sqlite3_with_extensions",
		&sqlite3.SQLiteDriver{
			Extensions: []string{
				"sqlite3_mod_vtable",
			},
		})

	db, err := sql.Open("sqlite3_with_extensions", ":memory:")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	db.Exec("create virtual table repo using github(id, full_name, description, html_url)")

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