sqlite3.InterfaceError:错误绑定参数 1 - 可能不受支持的类型 [英] sqlite3.InterfaceError: Error binding parameter 1 - probably unsupported type

查看:12
本文介绍了sqlite3.InterfaceError:错误绑定参数 1 - 可能不受支持的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了无法解决的烦人错误..这是我的功能

def savePicture(pic):尝试:connection=sqlite3.connect('/home/faris/Desktop/site/site.db')db=connection.cursor()打印类型(pic.user.profile_picture)db.execute('INSERT INTO 图片(picture_id, caption, created_time, picture_url, link, username,full_name,profile_picture) VALUES (?,?,?,?,?,?,?,?)',[pic.id,图片说明,pic.created_time,pic.get_standard_resolution_url(),图片链接,pic.user.username,pic.user.full_name,pic.user.profile_picture])连接提交()连接.close()除了 sqlite3.IntegrityError:打印图片已经存在"

这是我的表 (Sqlite:D)

-- 描述图片创建表图片"(picture_id"整数主键,标题"文本,created_time"文本,图片网址"文本,链接"文本,用户名"文本,全名"文本,个人资料图片"文本)

这是我遇到的错误,

回溯(最近一次调用最后一次):文件/home/faris/Desktop/site/cron/pictures.py",第 15 行,在 <module> 中保存图片(图片)文件/home/faris/Desktop/site/db.py",第 36 行,在 savePicture 中pic.user.profile_picturesqlite3.InterfaceError:错误绑定参数 1 - 可能不受支持的类型.

如你所见,我已经打印了pic.user.profile_picture"的类型,它返回了 str我也尝试使用这两个函数( unicode 和 str )只是为了确保它返回一个没有运气的字符串..

有什么想法吗?欢呼:D

解决方案

好吧,那太蠢了,哈哈

 pic.caption,pic.created_time,

不是 TEXT 类型..但错误消息说明了问题来自 pic.user.profile_picture.因此,如果您遇到此错误只需检查所有参数 :)

<块引用><块引用>

阅读下面的评论:)

I am having this annoying error that I could not solve.. here is my function

def savePicture(pic):
try:
    connection=sqlite3.connect('/home/faris/Desktop/site/site.db')
    db=connection.cursor()
    print type(pic.user.profile_picture)
    db.execute('INSERT INTO pictures (picture_id, caption, created_time, picture_url, link, username,full_name,profile_picture) VALUES (?,?,?,?,?,?,?,?)',
        [
        pic.id,
        pic.caption,
        pic.created_time,
        pic.get_standard_resolution_url(),
        pic.link,
        pic.user.username,
        pic.user.full_name,
        pic.user.profile_picture
        ])
    connection.commit()
    connection.close()
except sqlite3.IntegrityError:
    print 'pic already exist'

And here is my Table (Sqlite :D )

-- Describe PICTURES
CREATE TABLE "pictures" (
"picture_id" INTEGER PRIMARY KEY,
"caption" TEXT,
"created_time" TEXT,
"picture_url" TEXT,
"link" TEXT,
"username" TEXT,
"full_name" TEXT,
"profile_picture" TEXT
)

And this is the error I am having,

<type 'str'>
Traceback (most recent call last):
File "/home/faris/Desktop/site/cron/pictures.py", line 15, in <module>
savePicture(picture)
File "/home/faris/Desktop/site/db.py", line 36, in savePicture
pic.user.profile_picture
sqlite3.InterfaceError: Error binding parameter 1 - probably unsupported type.

As you see I have printed the type of the "pic.user.profile_picture" and it returned str I have also tried using these two functions ( unicode and str ) just to make sure that it is returning a string with no luck..

Any ideas? cheers :D

解决方案

Ok, That is stupid lol

    pic.caption,
    pic.created_time,

are not TEXT type..but the error msg is saying the problem from pic.user.profile_picture. thus, if you have this error just check all the parameters :)

Read the comment below :)

这篇关于sqlite3.InterfaceError:错误绑定参数 1 - 可能不受支持的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆