2017-08-24 53 views
0

我有一个数据库wxpython GUI供我的供应商使用,此插入新的供应商功能我正在创建一个新的供应商联系人。我无法找到导致此错误的原因。该函数在下面以及发生错误的位置。插入新数据时sqlite3操作错误

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

您对'self'不匹配前面的一个 – Mangohero1

+1

您有一个地址后加上逗号下一行缩进那不应该在那里。更改: TechnicalContactEmail,地址,到TechnicalContactEmail,地址 –

回答

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())) 
+0

是啊!谢谢 – mickNeill