You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Load a Tables.jl input `source` into an SQLite table that will be named `tablename` (will be auto-generated if not specified).
221
221
222
222
* `temp=true` will create a temporary SQLite table that will be destroyed automatically when the database is closed
223
223
* `ifnotexists=false` will throw an error if `tablename` already exists in `db`
224
-
* `replace=false` controls whether an `INSERT INTO ...` statement is generated or a `REPLACE INTO ...`
224
+
* `on_conflict=nothing` allows to specify an alternative [constraint conflict resolution algorithm](https://sqlite.org/lang_conflict.html): "ABORT", "FAIL", "IGNORE", "REPLACE", or "ROLLBACK".
225
+
* `replace=false` controls whether an `INSERT INTO ...` statement is generated or a `REPLACE INTO ...`. This keyword argument exists for backward compatibility, and is overridden if an algorithm is selected using the `on_conflict` keyword.
225
226
* `analyze=true` will execute `ANALYZE` at the end of the insert
226
227
"""
227
228
function load! end
@@ -292,6 +293,7 @@ function load!(
292
293
st =nothing;
293
294
temp::Bool=false,
294
295
ifnotexists::Bool=false,
296
+
on_conflict::Union{String, Nothing}=nothing,
295
297
replace::Bool=false,
296
298
analyze::Bool=false,
297
299
)
@@ -306,7 +308,7 @@ function load!(
306
308
# build insert statement
307
309
columns =join(esc_id.(string.(sch.names)), ",")
308
310
params =chop(repeat("?,", length(sch.names)))
309
-
kind = replace ?"REPLACE":"INSERT"
311
+
kind =isnothing(on_conflict) ? (replace ?"REPLACE":"INSERT") :"INSERT OR $on_conflict"
310
312
stmt =Stmt(
311
313
db,
312
314
"$kind INTO $(esc_id(string(name))) ($columns) VALUES ($params)";
0 commit comments