import pymysql config = { 'host': '127.0.0.1', 'port': 3306, 'user': 'root', 'password': 'root', 'database': 'sys', 'cursorclass': pymysql.cursors.DictCursor # 查询结果返回json } con = pymysql.connect(**config) cur = con.cursor() sql = """select * from sys_config""" cur.execute(sql) all_obj = cur.fetchall() print(all_obj) cur.close() con.close()
标签:cur,python,pymysql,mysql,close,操作,config,con From: https://www.cnblogs.com/nicole-zhang/p/17061769.html