Skip to content

Commit cb0abaa

Browse files
committed
Update transaction with more sane default
1 parent 8589148 commit cb0abaa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/DBInterface.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,16 @@ function with no transaction. Used in `DBInterface.executemany` to wrap the
163163
individual execute calls in a transaction since this often leads to much better
164164
performance in database systems.
165165
"""
166-
transaction(f, ::Connection) = f()
166+
function transaction(f, conn::Connection)
167+
execute(conn, "BEGIN TRANSACTION;")
168+
try
169+
f()
170+
execute(conn, "COMMIT;")
171+
catch e
172+
execute(conn, "ROLLBACK;")
173+
rethrow(e)
174+
end
175+
end
167176

168177
struct LazyIndex{T} <: AbstractVector{Any}
169178
x::T

0 commit comments

Comments
 (0)