gpt4 book ai didi

python - SQLite3语法错误调试

转载 作者:行者123 更新时间:2023-12-01 04:18:42 25 4
gpt4 key购买 nike

我很好奇,如何调试 SQLite3 语法。我每天都会使用这个 SQL,有时会遇到无法修复的语法错误。

例如这个查询:

    self.cur.execute("""INSERT INTO table(?,?,?,?,?,?,?,?,?,?,?,?,?) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)""", ('category', 'product_number', 'product', 'availability', 'manufacturer', 'weight', 'inner', 'outer', 'width', 'list_price', 'discount', 'gross_price', 'net_price', u'Wellenscheiben BKAGI..', 'BKAGI15', '-', 'This', 'PePS', '138,00', '50,00', '78,00', '6,50', '36,93', '55,00', '19,78', '16,62'))

sqlite3.OperationalError: near "?": syntax error

你知道如何找出错误所在吗?

最佳答案

您是否尝试过设置此标志:

sqlite3.enable_callback_tracebacks(True)

以下是文档:https://docs.python.org/2/library/sqlite3.html#sqlite3.enable_callback_tracebacks

编辑:我自己尝试过,在这种情况下没有多大帮助。您还可以尝试记录执行的sql,如下所示:https://stackoverflow.com/a/13647368/1338845然后看看该sql是否是它应该的样子。

关于python - SQLite3语法错误调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33999849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com