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

  • A+
所属分类:程序开发

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()
  • 公众号
  • 扫一扫
  • weinxin
  • 打赏
  • 扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: