关于pymysql报错问题TypeError: d format: a number is required not str

Oria ·
更新时间:2024-09-20
· 908 次阅读

关于pymysql报错TypeError %d format a number is required,not str问题 现场环境:

python 3.8.1 ,pymysql 0.9.3

放报错代码 import pymysql def getCollectToMysql(): # 打开数据库连接 dbConnect = pymysql.connect(host='localhost',user='root',passwd='root',db='issuehandledb',port=3306,charset='utf8') # 使用cursor()方法获取操作游标 cursor = dbConnect.cursor() return cursor, dbConnect #使用列表内元组的方式增加 def insertDataToMysql(cursor, dbConnect, insertData, sql): try: cursor.execute(sql, insertData) dbConnect.commit() except: # Rollback in case there is any error # 输出异常信息 print(insertData) traceback.print_exc() dbConnect.rollback() if __name__ == '__main__': cursor,dbConnect = getCollectToMysql() insertsql = 'insert into issuehandledb.userinfo(id,username,password,privilege,isused) values(%d,%s,%s,%d,%s);' result = (8,'xccc','sss',4,'1') insertDataToMysql(cursor,dbConnect,result,insertsql) cursor.close() dbConnect.close()

报错如下:
原创文章 1获赞 1访问量 21 关注 私信 展开阅读全文
作者:圈点圈点圈



str number format NOT IS pymysql

需要 登录 后方可回复, 如果你还没有账号请 注册新账号
相关文章