0
import mysql.connector
import sys
from PIL import Image
import base64
import cStringIO
import PIL.Image

db = mysql.connector.connect(user='root', password='abhi',
                              host='localhost',
                              database='cbir')
sql = 'INSERT INTO fgh(id,name) VALUES(%d,%s)'    
args = (1,'abhi')
cursor=db.cursor()
cursor.execute(sql,args)
db.commit()
db.close()

error:

Traceback (most recent call last):
  File "C:\Users\Abhi\Desktop\cbir-p\New folder\co.py", line 16, in <module>
    cursor.execute(sql,args)
  File "C:\Python27\lib\site-packages\mysql\connector\cursor.py", line 472, in execute
    "Wrong number of arguments during string formatting")
ProgrammingError: Wrong number of arguments during string formatting

help me solve this error

1 Answer 1

1

I believe that all MySQL parameter markers should be %s. Try replacing the %d with %s and see if that fixes it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.