我已经尝试了一切并不断收到此错误:
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格式扩展后):
SELECT value INTO @var FROM tabSingles WHERE doctype = 'Bank Reconciliation' AND field = 'bank_account';
INSERT INTO tabSingles (doctype, field, value) VALUES ('Bank Reconciliation', 'account', @var);
DELETE FROM tabSingles WHERE doctype = 'Bank Reconciliation' AND field = 'bank_account';
任何人都可以看到问题吗?多行查询有问题吗?我已经尝试了 mariadb 命令行上的各个行,它们似乎按预期工作。我也尝试过 frappe.db.sql 和 multisql (认为它意味着多行 sql 但不是)。如果我将第 2 行注释掉,则第 3 行也会出错。很抱歉打扰,但我已经盯着这个看了好几个小时了,无法弄清楚!
编辑:显而易见的答案是这样,但我仍然想知道为什么它不喜欢原始查询:
UPDATE tabSingles SET field='{new_name}' WHERE doctype='{doctype}' AND field='{old_name}';