聆听风声 点点滴滴都很珍贵!

python查找mysql返回字典类型数据

2019-02-15

python查找mysql返回字典类型数据

import mysql.connector 


config = {'user': 'root', 'password': '', 'host': '127.0.0.1', 'port': '3306', 'database': 'entcredits2',
              'raise_on_warnings': True,}



cnx = mysql.connector.connect(**config)
cursor = cnx.cursor(dictionary=True)



select_sql = "select * from entcredits_companyinfo where com_name='上海源庐投资管理有限公司'"
cursor.execute(select_sql)
result = cursor.fetchall()
cursor.close()
cnx.close()

Similar Posts

Comments