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
executemany() does not translate pyformat dict params #807
Cursor.executemany() with pyformat %(name)s SQL and a list of dicts raises a SQLParseException in crate-python 2.2.0. The pyformat→positional translation introduced in dev is never applied on the bulk code path, raw %(name)s SQL is forwarded to CrateDB's HTTP API, which does not understand pyformat syntax.
Root cause
executemany()does not passes seq_of_parameters as parameters:
execute() only calls _convert_named_to_positional() when isinstance(parameters, dict) (line 101). The bulk_parameters argument is never inspected for pyformat translation.
As a result, the following JSON body is sent to CrateDB's /_sql endpoint:
{
"stmt": "INSERT INTO t (name, age) VALUES (%(name)s, %(age)s)",
"bulk_args": [{"name": "Arthur", "age": 42}]
}
CrateDB's SQL parser rejects the %(...)s syntax:
SQLParseException[Failed to parse source [...]]
Reproduction
importcrate.clientascrate_clientconn=crate_client.connect("localhost:4200")
cur=conn.cursor()
cur.execute(
"CREATE TABLE IF NOT EXISTS t (name TEXT PRIMARY KEY, age INT) ""WITH (number_of_replicas = 0)"
)
# FAILScur.executemany(
"INSERT INTO t (name, age) VALUES (%(name)s, %(age)s)",
[
{"name": "Arthur", "age": 42},
{"name": "Trillian", "age": 35},
],
)
Activity