sqlite3.ProgrammingError:提供的绑定数不正确。当前语句使用1def insert(array):
connection=sqlite3.connect('images.db')
cursor=connection.cursor()
cnt=0
while cnt != len(array):
img = array[cnt]
print(array[cnt])
cursor.execute('INSERT INTO images VALUES(?)', (img))
cnt+= 1
connection.commit()
connection.close()我不知道为什么会出现错误,我试图插入的实际字符串有74个字符长,它是:“/gifs/epic-fail-photos-there-i-fixed-it-aww-man-the-tire-pressures-low.gif”在插入之前,我尝试过str(Array[cnt]),但是同样的问题正在发生,数据库只有一个列,这是一个文本值。我已经干了好几个小时了,我搞不懂到底是怎么回事。
2 回答

繁星点点滴滴
TA贡献1803条经验 获得超3个赞
cursor.execute('INSERT INTO images VALUES(?)', (img,))
(img)
img
>>> len(img)74>>> len((img,))1
cursor.execute('INSERT INTO images VALUES(?)', [img])
添加回答
举报
0/150
提交
取消