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()
错误:
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
帮我解决这个错误
答案 0 :(得分:1)
我相信所有MySQL参数标记都应该是%s
。尝试将%d
替换为%s
,看看是否可以修复它。