我正在编写一个需要在db
中插入值的脚本我写过像
这样的查询cur.execute('''INSERT into agent_info set (didNo,agentNumber,agentOrder,agentName,agentId,agentEmail,dateOfCreation,agentStatus,) values (%s,%s,%s,%s,%s,%s,%s,%s) ''',(row[0],row[2],'1','SomeName',id_generator(),'hey',ti,'FREE'))
但我在agentStatus
这是错误:
ProgrammingError(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(didNo,agentNumber,agentOrder,agentName,agentId,agentEmail,dateOfCreation,agentS' at line 1")
答案 0 :(得分:1)
您的逗号太多,需要删除 set
:
INSERT into agent_info set
-- ^^^
(didNo,agentNumber,agentOrder,agentName,agentId,
agentEmail,dateOfCreation,agentStatus,)
-- ----------^
values (%s,%s,%s,%s,%s,%s,%s,%s)
更正声明:
INSERT into agent_info
(didNo,agentNumber,agentOrder,agentName,agentId,
agentEmail,dateOfCreation,agentStatus)
values (%s,%s,%s,%s,%s,%s,%s,%s)
SET
只应在MySQL INSERT INTO <table> SET col1=val1, col2=val2
非标准SQL扩展中使用。