Skip to content

Commit

Permalink
Update transaction with more sane default
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Feb 16, 2024
1 parent 8589148 commit cb0abaa
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/DBInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,16 @@ function with no transaction. Used in `DBInterface.executemany` to wrap the
individual execute calls in a transaction since this often leads to much better
performance in database systems.
"""
transaction(f, ::Connection) = f()
function transaction(f, conn::Connection)
execute(conn, "BEGIN TRANSACTION;")
try
f()
execute(conn, "COMMIT;")
catch e
execute(conn, "ROLLBACK;")
rethrow(e)
end
end

struct LazyIndex{T} <: AbstractVector{Any}
x::T
Expand Down

0 comments on commit cb0abaa

Please sign in to comment.