Not all arguments converted during string formatting

thumbnail and image are the BLOB field, num1 and num2 are the whole field, others are Str.

I want to insert binary data into MYSQL. But when this line was called, an error occurred.

 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.

+4
source share
1 answer

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)) 
+5
source

Source: https://habr.com/ru/post/1342419/


All Articles