Python mariadb的简单多行SQL查询中的pymysql.err.ProgrammingError 1064

Python mariadb的简单多行SQL查询中的pymysql.err.ProgrammingError 1064,python,mariadb,erpnext,Python,Mariadb,Erpnext,我已尝试了所有方法,但不断出现以下错误: pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO tabSingles (doctype, field, value) VALUES

我已尝试了所有方法,但不断出现以下错误:

pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for the right syntax to use near
'INSERT INTO tabSingles (doctype, field, value) VALUES ('Bank Reconciliation', 'a' at line 2")
扩展查询(在python格式扩展之后):

有人看到问题了吗?多行查询是否存在问题?我在mariadb命令行上尝试了单独的几行,它们似乎按预期工作。我还尝试了frappe.db.sql和multisql(虽然它意味着多行sql,但实际上并非如此)。如果我将第2行注释掉,第3行也会出现错误。抱歉打扰了,我已经盯着这个看了好几个小时了,想不出来了

编辑: 显而易见的答案是这样的,但我仍然想知道为什么它不喜欢原始查询:

UPDATE tabSingles SET field='{new_name}' WHERE doctype='{doctype}' AND field='{old_name}';
出于安全原因(主要是SQL注入),默认情况下,MariaDB(和MySQL)服务器不支持执行多个SQL语句


为了支持多个语句的执行,客户端需要向服务器发送
COM\u SET\u OPTION
命令和
MYSQL\u OPTION\u MULTI\u statements\u ON
标志,这是PyMySQL不支持的。不要尝试在调用中运行多个语句

务必使用
BEGIN
COMMIT

请务必使用
进行更新

您需要5个单独的命令:

BEGIN;
SELECT ... FOR UPDATE;  -- to keep other connections from messing with the row(s).
UPDATE ...;
DELETE ...
COMMIT;   -- do all of the above "atomically"

你能给出一个python代码不起作用的例子吗?FWWW,我会考虑这3个单行查询,而不是多行查询。@ TouthHACK我可以,但我不认为它会有帮助吗?文章中的查询是在发送到db的格式扩展后从python打印的单个字符串
BEGIN;
SELECT ... FOR UPDATE;  -- to keep other connections from messing with the row(s).
UPDATE ...;
DELETE ...
COMMIT;   -- do all of the above "atomically"