0

我的程序引发sqlite3.OperationalError异常并显示以下消息:

: near ",": syntax error

我有一个 try-except 块,可以打印我的 SQL 字符串。:

try:
    self._db_cur.execute(sql)
except Exception, e:
    print sql
    raise e

这是打印出来的 SQL……最有趣的部分是……如果我在我的 SQLite 管理器中插入该查询……它确实可以工作。我在这里一无所知。

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")
)

由于某些原因,我没有使用参数化语句,如果它有帮助的话......

4

1 回答 1

3

这可能是sqlite3.

虽然测试代码适用于 python3.3 和 sqlite 3.7.15.2,但它适用于 sqlite 3.7.3失败

这意味着它应该在较新的版本中得到修复,因此您需要更新您的 sqlite 版本(或 python)以使其工作,或者通过不使用多个值集来解决这个问题。


*edit:其实不是bug,只是3.7.11版本才引入的功能

于 2013-07-06T14:47:43.927 回答