-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
How to load the json1 extension? #832
Copy link
Copy link
Open
Description
Hello,
I'm trying to load the json1 extension. I know you can do it by specifying the --tags option in your go build command. But just wanted to know if its possible to load it during runtime. I tried doing it but no luck. Here's the code snippet:
import (
"database/sql"
"github.com/mattn/go-sqlite3"
)
func connect(dbPath string) error {
sql.Register("sqlite3_json1", &sqlite3.SQLiteDriver{
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
if err := conn.LoadExtension("sqlite_json1", ""); err != nil {
return err
}
return nil
},
})
dbc, err := sql.Open("sqlite3", dbPath)
if err != nil {
return nil, err
}
return nil
}
Please advise. Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels