My programme raises an sqlite3.OperationalError exception with the following message:
: near ",": syntax error
I have a try-except block that prints me the SQL string.:
try:
self._db_cur.execute(sql)
except Exception, e:
print sql
raise e
This is the printed SQL... the most interesting part is... that if I insert that query in my SQLite manager... it DOES work. I'm clueless here.
INSERT INTO connections_to_jjos(
connections_id,
jjo_error_id,
binder_task_id
)
VALUES
(
55,
(select id from jjo_errors where name = "--Unknown--"),
(select id from tasks where name = "DCDD")
)
,
(
55,
(select id from jjo_errors where name = "--Unknown--"),
(select id from tasks where name = "ANDD")
)
For some reasons, I am not using parameterized statements, if it helps...
1 Answer 1
This is probably a bug* in sqlite3.
While this test code works fine with python3.3 and sqlite 3.7.15.2, it fails with sqlite 3.7.3.
That means it should be fixed in newer versions, so you'd need to update your sqlite version (or python) to make it work, or work around this by not using multiple values sets.
*edit: actually not a bug, just a feature that was only introduced in version 3.7.11
VALUES->(->expr->)->,->(->exp->)->,... BUT I just googled multiples values in SQLite, and apparently it is not a valid statement. There are workarounds, though..executemany()instead.