【问题标题】:sqlite InterfaceError: Error binding parameter 0 - probably unsupported typesqlite InterfaceError:错误绑定参数0 - 可能不受支持的类型
【发布时间】:2012-02-28 19:17:29
【问题描述】:

我正在使用 sqlite3 python 模块,下面的代码返回错误

InterfaceError: Error binding parameter 0 - 可能是不支持的类型

注意,我已经尝试过使用普通(非 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)

【问题讨论】:

  • 您发布的代码对我来说很好用。附注:尽量避免使用内置名称作为变量名。

标签: database sqlite python-2.7


【解决方案1】:

这段代码对我来说很好用。

但是,您是否完全更改了表架构?因为你添加了

 create if not exists

很可能您更改了某些内容,但数据库(文件)没有更新,因为您有这个。

此外,即使类型是文本,您也会为 exid 传递一个 int。它会自动转换它,但仍然不应该这样做。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-24
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多