私は解決できなかったこの厄介なエラーを抱えています..ここに私の機能があります
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 を返しました。また、これら 2 つの関数 ( unicode と str ) を使用して、運のない文字列が返されていることを確認しました。
何か案は?乾杯:D