Based on reading the docs at GitHub - JuliaDatabases/DBInterface.jl: Database interface definitions for Julia, I thought that I could use named parameters in a prepared statement to update data, which did not work. However, the positional parameters worked fine. Can someone help me understand what I did wrong?
using DuckDB, DataFrames
con = DBInterface.connect(DuckDB.DB, ":memory:")
DBInterface.execute(con, """
CREATE TABLE tab (
name TEXT PRIMARY KEY,
data INTEGER
);
""")
DBInterface.execute(con, """
INSERT INTO tab VALUES
('a', 5),
('b', 10);
""")
DBInterface.execute(con, "SELECT * FROM tab;") |> DataFrame
# fails
stmt = DBInterface.prepare(con, """
UPDATE tab
SET data = :dat
WHERE name IN :names;
""")
DBInterface.execute(stmt, (:dat=50, :names=["b"]))
# works
stmt = DBInterface.prepare(con, """
UPDATE tab
SET data = ?
WHERE name IN ?;
""")
DBInterface.execute(stmt, [50, ["b"]])
DBInterface.execute(con, "SELECT * FROM tab;") |> DataFrame