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
{{ message }}
Repository navigation
Prepare with named Arguments Failing for MySQL #46
So I have a simple test table that looks like this:
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| id | int(11) | YES | | <null> | |
| pname | varchar(255) | YES | | <null> | |
+-------+--------------+------+-----+---------+-------+
I connect to the database successfully and then try to insert some values using named arguments such as this,
stmt = DBInterface.prepare(conn,"insert into test values(:id, :pname) ;")
This results in the error:
julia> stmt = DBInterface.prepare(conn,"insert into test values(:id, :pname) ;")
ERROR: (1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':id, :pname)' at line 1
Stacktrace:
[1] prepare
@ ~/.julia/packages/MySQL/tCDUl/src/api/papi.jl:4 [inlined]
[2] prepare(conn::MySQL.Connection, sql::String; mysql_date_and_time::Bool)
@ MySQL ~/.julia/packages/MySQL/tCDUl/src/prepare.jl:48
[3] prepare(conn::MySQL.Connection, sql::String)
@ MySQL ~/.julia/packages/MySQL/tCDUl/src/prepare.jl:45
[4] top-level scope
@ /data/projects/Stocks/testsql.jl:17
If I use positional arguments it works fine. However positional arguments can't handle more complicated queries wherein a given argument must appear multiple times within the query.
DBInterface does not rewrite SQL placeholders. MySQL prepared statements support positional ? markers only; repeat the marker and value when the same value is used more than once. v2.7.0 now documents driver-specific placeholder support. Closing as answered.
Activity
quinnj commentedon Aug 10, 2026
DBInterface does not rewrite SQL placeholders. MySQL prepared statements support positional
?markers only; repeat the marker and value when the same value is used more than once. v2.7.0 now documents driver-specific placeholder support. Closing as answered.[reviewed by quinnj, posted by codex]