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()
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()
相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- install and upgrade scrapy
- source命令执行SQL脚本文件
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- MySQL创建用户及权限控制
- MySQL管理数据表