您的位置:首页 > 编程语言 > Python开发

python3 MySQL 查询返回字典类型

2016-06-03 14:35 609 查看
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