![](/img/trans.png)
[英]Django migrate error _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax
[英]_mysql_exceptions.ProgrammingError: (1064, “You have an error in your SQ L syntax; right syntax to use near ')' at line 1”)
Python MySQL語句返回錯誤
def _conditional_insert(self, tx, item):
tx.execute('select * from table where text1 = %s', (item['text1'], ))
result = tx.fetchone()
if result:
log.msg("Item already stored in db: %s" % item, level=log.DEBUG)
else:
tx.execute(\
"INSERT INTO table (text3 table, text1, text2) "
"values (%s, %s, %s, %s)",
(item['text3'],
item['table'],
item['text1'],
item['text2'],
)
)
log.msg("Item stored in db: %s" % item, level=log.DEBUG)
def handle_error(self, e):
log.err(e)
但不斷出現以下錯誤:
_mysql_exceptions.ProgrammingError:(1064,“您的SQ L語法有誤;請在與MySQL服務器版本相對應的手冊中在第1行的')'附近使用正確的語法”)
可有人告訴我哪里忽略不計)?
您的字段規格中的text3
后缺少逗號。
INSERT INTO table (text3 table, text1, text2)
應該:
INSERT INTO table (text3, table, text1, text2)
另外,如果您不將表名用引號引起來,我也不認為table
是有效的表名或列名,因為它是關鍵字。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.