Skip to content

Commit 7be68ef

Browse files
committed
Fix #151 by adding a function to enable extension loading
1 parent 44c9f40 commit 7be68ef

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

docs/src/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ re-execute the query and position the iterator back at the begining of the resul
106106

107107
List the indices that have been created in `db`
108108

109+
* `SQLite.enable_load_extensions(db::SQLite.DB, enable::Bool=true)`
110+
111+
Enables extension loading (off by default) on the sqlite database `db`. Pass `false` as the second argument to disable.
109112

110113
* `SQLite.register(db::SQLite.DB, func::Function; nargs::Int=-1, name::AbstractString=string(func), isdeterm::Bool=true)`
111114

src/SQLite.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,4 +437,13 @@ returns the auto increment id of the last row
437437
"""
438438
last_insert_rowid(db::DB) = sqlite3_last_insert_rowid(db.handle)
439439

440+
"""
441+
`SQLite.enable_load_extension(db, enable::Bool=true)`
442+
443+
Enables extension loading (off by default) on the sqlite database `db`. Pass `false` as the second argument to disable.
444+
"""
445+
function enable_load_extension(db, enable::Bool=true)
446+
ccall((:sqlite3_enable_load_extension, SQLite.libsqlite), Cint, (Ptr{Cvoid}, Cint), db.handle, enable)
447+
end
448+
440449
end # module

test/runtests.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ cp(dbfile, dbfile2; force=true)
2323
chmod(dbfile2, 0o777)
2424
db = SQLite.DB(dbfile2)
2525

26-
@testset "SQLite" begin
27-
2826
# regular SQLite tests
2927
ds = SQLite.Query(db, "SELECT name FROM sqlite_master WHERE type='table';") |> columntable
3028
@test length(ds) == 1
@@ -293,4 +291,4 @@ SQLite.execute!(q)
293291
SQLite.bind!(q, 1, "a")
294292
@test_throws SQLite.SQLiteException SQLite.execute!(q)
295293

296-
end #@testset
294+
@test SQLite.@OK SQLite.enable_load_extension(db)

0 commit comments

Comments
 (0)