registered custom cgo sqlite driver
This commit is contained in:
+4
-2
@@ -19,7 +19,7 @@ func init() {
|
||||
// Note 2: the busy_timeout pragma must be first because
|
||||
// the connection needs to be set to block on busy before WAL mode
|
||||
// is set in case it hasn't been already set by another connection.
|
||||
sql.Register("sqlite3_with_connect_hook",
|
||||
sql.Register("pb_sqlite3",
|
||||
&sqlite3.SQLiteDriver{
|
||||
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
|
||||
_, err := conn.Exec(`
|
||||
@@ -34,10 +34,12 @@ func init() {
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
dbx.BuilderFuncMap["pb_sqlite3"] = dbx.BuilderFuncMap["sqlite3"]
|
||||
}
|
||||
|
||||
func connectDB(dbPath string) (*dbx.DB, error) {
|
||||
db, err := dbx.Open("sqlite3_with_connect_hook", dbPath)
|
||||
db, err := dbx.Open("pb_sqlite3", dbPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user