2017-08-24 62 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