我遇到了这个我无法解决的烦人错误。这是我的功能
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'
这是我的表(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
)
这是我遇到的错误,
<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.
如您所见,我已经打印了“pic.user.profile_picture”的类型并返回了 str 我还尝试使用这两个函数( unicode 和 str ),以确保它返回一个没有运气的字符串。
有任何想法吗?欢呼:D