2012-02-28 39 views
1

我使用sqlite3的Python模塊和次下面的代碼返回錯誤sqlite的InterfaceError:錯誤綁定參數0 - 可能是不支持的類型

InterfaceError: Error binding parameter 0 - probably unsupported type

注意我已經嘗試與正常(非Unicode)的字符串,其結果是相同

# get database cursor 
cur = dbConnection.cursor() 

# create table for prices 
cur.execute(""" 
    create table if not exists 
    prices(time text,      
      mid integer, 
      exid text, 
      selid integer,      
      priceone real, 
      sometext text, 
      price2 real, 
      primary key (time, mid, exid, selid, priceone) 
      foreign key (time, mid, exid, selid) references selection(time, mid, exid,selid))""") 

#insert price 
tuple = (u'20120228153239788135', 104982590, 1, 4764315, 1.99, u'B', 0.07) 
cur.execute("insert into prices values (?,?,?,?,?,?,?)", tuple) 
+0

您發佈的代碼適合我。附註:儘量避免使用內置名稱作爲變量名稱。 – bernie 2012-02-28 21:50:16

回答

2

此代碼適合我。

但是,你有沒有改變你的表格模式?因爲你添加了

create if not exists 

它很可能是你改變了一些東西,但數據庫(文件)沒有更新,因爲你有這個。

另外,即使類型是文本,也要傳入一個用於exid的int。它會自動轉換它,但仍不應該這樣做。

相關問題