mirror of https://github.com/mattn/go-sqlite3.git
Add new driver name 'sqlite3_with_extensions'
This commit is contained in:
parent
34a33cffaa
commit
f6dadd82d8
13
sqlite3.go
13
sqlite3.go
|
@ -72,11 +72,13 @@ var SQLiteTimestampFormats = []string{
|
|||
}
|
||||
|
||||
func init() {
|
||||
sql.Register("sqlite3", &SQLiteDriver{})
|
||||
sql.Register("sqlite3", &SQLiteDriver{false})
|
||||
sql.Register("sqlite3_with_extensions", &SQLiteDriver{true})
|
||||
}
|
||||
|
||||
// Driver struct.
|
||||
type SQLiteDriver struct {
|
||||
enableLoadExtentions bool
|
||||
}
|
||||
|
||||
// Conn struct.
|
||||
|
@ -176,6 +178,15 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
|
|||
return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))
|
||||
}
|
||||
|
||||
enableLoadExtentions := 0
|
||||
if d.enableLoadExtentions {
|
||||
enableLoadExtentions = 1
|
||||
}
|
||||
rv = C.sqlite3_enable_load_extension(db, C.int(enableLoadExtentions))
|
||||
if rv != C.SQLITE_OK {
|
||||
return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))
|
||||
}
|
||||
|
||||
return &SQLiteConn{db}, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue