我在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)
答案 0 :(得分:1)
您在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
我不认为反斜杠与它有任何关系。您的错误消息实际上是否将反斜杠视为问题?