diff --git a/sqlite3.go b/sqlite3.go index b95f290..0aba2db 100644 --- a/sqlite3.go +++ b/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 }