问题:如果直接插入一条某字段为 % ,会报错。
作者:互联网
# -*- coding: utf-8 -*- import pymysql.cursors connect = pymysql.Connect( host='**********', port=3306, user='root', passwd='123456', db='ry', charset='utf8' ) def judge(): cursor = connect.cursor() sql ="INSERT INTO test_log(rwmc, scenario) VALUES ('%%', '%s');" data = 'bb' cursor.execute(sql % data) connect.commit() print('成功插入', cursor.rowcount, '条数据') if __name__ == '__main__': judge()
标签:__,某字,直接插入,pymysql,cursor,报错,connect,sql,judge 来源: https://www.cnblogs.com/yszr/p/15028862.html