2014-01-23 05:56:01 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2018-06-15 18:53:32 +03:00
|
|
|
"os"
|
2017-03-05 16:29:09 +03:00
|
|
|
|
2018-07-20 15:51:46 +03:00
|
|
|
"github.com/mattn/go-sqlite3/driver"
|
2014-01-23 05:56:01 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
2018-06-15 18:53:32 +03:00
|
|
|
_, err = db.Exec("create virtual table repo using github(id, full_name, description, html_url)")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2014-01-23 05:56:01 +04:00
|
|
|
|
|
|
|
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() {
|
2017-03-05 16:29:09 +03:00
|
|
|
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)
|
2014-01-23 05:56:01 +04:00
|
|
|
}
|
2018-06-15 18:53:32 +03:00
|
|
|
|
|
|
|
fmt.Println("Clean Exit")
|
|
|
|
os.Exit(0)
|
2014-01-23 05:56:01 +04:00
|
|
|
}
|