gpt4 book ai didi

python - 由于字符串值之一的 "\",mysql 查询失败

转载 作者:行者123 更新时间:2023-11-29 11:22:50 25 4
gpt4 key购买 nike

我使用 python 中的 Excel 工作表生成查询,然后使用 conn.execute(query) 执行查询。

但是,一个查询失败,因为它在某个值字符串的末尾有 \。在下面的查询中查找 VALUES ("test", "ABCD\":

INSERT INTO S_account(Sub, AccName, AccTeam, Terr, AccOwner,
Level1, GAccount, Customer, City, State, EndCusName, AccID)
VALUES ("test", "ABCD\", "test", "test", "test", "No", "Yes",
"test", "test", "test", "asdasdas")
ON DUPLICATE KEY UPDATE
Sub = VALUES(Sub), AccName = VALUES(AccName), AccTeam = VALUES(AccTeam),
Terr = VALUES(Terr), AccOwner = VALUES(AccOwner), Level1 = VALUES(Level1),
GAccount = VALUES(GAccount), Customer = VALUES(Customer),
City = VALUES(City), State = VALUES(State), EndCusName = VALUES(EndCusName)

我尝试了以下命令,但没有帮助。

query = re.sub('\$', '' query)

最佳答案

您在 INSERT 语句中指定了 12 列,但仅包含 11 列的值:

INSERT INTO S_account(Sub, AccName, AccTeam, Terr, AccOwner, Level1,
GAccount, Customer, City, State, EndCusName, AccID)
VALUES ("test", "ABCD\", "test", "test", "test", "No",
"Yes", "test", "test", "test", "asdasdas", MISSING) -- no value for AccID

我认为反斜杠与它没有任何关系。您的错误消息实际上是否提到反斜杠是一个问题?

关于python - 由于字符串值之一的 "\",mysql 查询失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38648696/

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