# -*- 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()