我的供应商有一个数据库wxpython GUI,在这个插入新的供应商功能中,我正在创建一个新的供应商联系人。我找不到导致此错误的原因。该功能在下面以及发生错误的位置。
def insertNew(self,event):
with con:
cur = con.cursor()
cur.execute("INSERT OR IGNORE INTO Suppliers (Supplier, Code, Commodity, Contact, Number, EmailContact, TechnicalContact, TechnicalContactEmail, Address,) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)",
(self.text_list[0].GetValue(), self.text_list[1].GetValue(), self.text_list[2].GetValue(), self.text_list[3].GetValue(), self.text_list[4].GetValue(),
self.text_list[5].GetValue(), self.text_list[6].GetValue(), self.text_list[7].GetValue(), self.text_list[8].GetValue()))
con.commit()
错误是
Traceback (most recent call last):
File "C:\Users\ONP1LDY\eclipse-workspace\WOrk\SupplierDB.py", line 169, in insertNew
self.text_list[5].GetValue(), self.text_list[6].GetValue(), self.text_list[7].GetValue(), self.text_list[8].GetValue()))
sqlite3.OperationalError: near ")": syntax error
任何人都可以看到错误的来源吗?
答案 0 :(得分:2)
你需要在Adress
之后删除逗号,它正在等待另一个列标识符:
cur.execute("INSERT OR IGNORE INTO Suppliers (Supplier, Code, Commodity, Contact, Number, EmailContact, TechnicalContact, TechnicalContactEmail, Address) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)",
(self.text_list[0].GetValue(), self.text_list[1].GetValue(), self.text_list[2].GetValue(), self.text_list[3].GetValue(), self.text_list[4].GetValue(),
self.text_list[5].GetValue(), self.text_list[6].GetValue(), self.text_list[7].GetValue(), self.text_list[8].GetValue()))