Reputation: 41
thumbnail
and image
are BLOB field, num1
and num2
are Integer field, others are Str.
I want to insert binary data into MYSQL. But When this line called, error occured.
cursor.execute("INSERT INTO image(num1, num2, filename, ext, thumbnail, image) VALUES(?, ?, ?, ?, ?, ?);" , (num1, num2, _name, _ext, _thumb, _image))
Error text: not all arguments converted during string formatting
How to fix it? Please teach me.
Upvotes: 4
Views: 6454
Reputation: 880887
If you are using MySQLdb, try:
cursor.execute("""
INSERT INTO image
(num1, num2, filename, ext, thumbnail, image) VALUES
(%s, %s, %s, %s, %s, %s)""" , (num1, num2, _name, _ext, _thumb, _image))
Upvotes: 5