moruru
moruru

Reputation: 41

not all arguments converted during string formatting

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

Answers (1)

unutbu
unutbu

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

Related Questions