第二种方式
# 打开数据库连接 db = pymysql.connect(host="192.168.88.11", user="root", password="123", db="aaa", port=3306) cur = db.cursor() try: for i in range(1000): cur.execute("insert into qqq values (‘ccc-%s‘)‘` %i) results = cur.fetchall() # 获取查询的所有记录 db.commit() #提交 except Exception as e: raise e finally: db.close() # 关闭连接python(pymysql操作数据库)
标签:for ISE student nal 查询 result value mys 游标