Python MySQL Statement returning Error
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)
but keep getting the following error :
但是继续得到以下错误:
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQ L syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1")
_mysql_exceptions。编程错误:(1064,“你的SQ语法有错误;检查与MySQL服务器版本对应的手册,找到正确的语法,在第1行使用“)”)
can someone tell where I ignored ) ?
有人能告诉我我忽略了哪里吗?
1 个解决方案
#1
4
You are missing a comma after text3
in your field spec.
在字段规范中,在text3后面缺少一个逗号。
INSERT INTO table (text3 table, text1, text2)
should be:
应该是:
INSERT INTO table (text3, table, text1, text2)
Also I don't think table
is a valid table or column name if you don't enclose it in quotes, because it is a keyword.
我也不认为表是一个有效的表或列名,如果你不把它括在引号中,因为它是一个关键字。
#1
4
You are missing a comma after text3
in your field spec.
在字段规范中,在text3后面缺少一个逗号。
INSERT INTO table (text3 table, text1, text2)
should be:
应该是:
INSERT INTO table (text3, table, text1, text2)
Also I don't think table
is a valid table or column name if you don't enclose it in quotes, because it is a keyword.
我也不认为表是一个有效的表或列名,如果你不把它括在引号中,因为它是一个关键字。