Fork github.com/mattn/go-sqlite3 with adjustment for go1.16.2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
872 B

  1. package main
  2. import (
  3. "database/sql"
  4. "fmt"
  5. "log"
  6. "github.com/mattn/go-sqlite3"
  7. )
  8. func main() {
  9. sql.Register("sqlite3_with_extensions", &sqlite3.SQLiteDriver{
  10. ConnectHook: func(conn *sqlite3.SQLiteConn) error {
  11. return conn.CreateModule("github", &githubModule{})
  12. },
  13. })
  14. db, err := sql.Open("sqlite3_with_extensions", ":memory:")
  15. if err != nil {
  16. log.Fatal(err)
  17. }
  18. defer db.Close()
  19. _, err = db.Exec("create virtual table repo using github(id, full_name, description, html_url)")
  20. if err != nil {
  21. log.Fatal(err)
  22. }
  23. rows, err := db.Query("select id, full_name, description, html_url from repo")
  24. if err != nil {
  25. log.Fatal(err)
  26. }
  27. defer rows.Close()
  28. for rows.Next() {
  29. var id, fullName, description, htmlURL string
  30. rows.Scan(&id, &fullName, &description, &htmlURL)
  31. fmt.Printf("%s: %s\n\t%s\n\t%s\n\n", id, fullName, description, htmlURL)
  32. }
  33. }