Python 插入新数据时发生sqlite3操作错误
我有一个用于我的供应商的数据库wxpython GUI,在这个插入新供应商功能中,我正在创建一个新的供应商联系人。我找不到导致此错误的原因。下面是函数以及错误发生的位置Python 插入新数据时发生sqlite3操作错误,python,sqlite,Python,Sqlite,我有一个用于我的供应商的数据库wxpython GUI,在这个插入新供应商功能中,我正在创建一个新的供应商联系人。我找不到导致此错误的原因。下面是函数以及错误发生的位置 def insertNew(self,event): with con: cur = con.cursor() cur.execute("INSERT OR IGNORE INTO Suppliers (Supplier, Code, Commo
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
有人能看到错误的来源吗?您需要删除
地址
后的逗号,它正在等待另一个列标识符:
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()))
您需要删除
地址
后的逗号,它正在等待另一个列标识符:
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()))
您在
self
的下一行的缩进与前面的缩进不匹配。您的地址后面有一个逗号,不应该在那里。更改:TechnicalContactEmail,Address,更改为TechnicalContactEmail,Address您在self
的下一行的缩进与前面的缩进不匹配您的地址后面有一个逗号,不应该在那里。更改:TechnicalContactEmail,地址,更改为TechnicalContactEmail,地址