def 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()
When I try insert("/gifs/epic-fail-photos-there-i-fixed-it-aww-man-the-tire-pressures-low.gif")
, I get an error message like in the title (the string is indeed 74 characters long).
What is wrong with the code, and how do I fix it?
The same problem occurs with MySQLdb
and many other popular SQL libraries. See Why do I get "TypeError: not all arguments converted during string formatting" when trying to use a string in a parameterized SQL query? for details.