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()
本文演示了如何使用Python的mysql.connector库连接到MySQL数据库并执行查询操作。通过具体的代码示例,展示了如何配置数据库连接参数、执行SQL查询及获取结果。

801

被折叠的 条评论
为什么被折叠?



