参考:为Python安装MySQL数据库模块:MySQLdb
实测安装 MySQL-python-1.2.5 时也出现同样的问题:Cannot open include file: ‘config-win.h’: No such file or directory,文章给出的解决方法是:
重新运行MySQL的安装程序,选择Modify,把“C Include Files / Lib Files”勾选上,并安装。
但在mysql 5.7.11 安装中没有安装 C Include Files 的选项。
解决:
1.安装了mysql-connector-python 模块(
https://dev.mysql.com/downloads/connector/python)
下载mysql-connector-c 库,mysql 5.7.11自带的 6.1版本不行,需要6.0.2版本,可在如下地址下载
http://dev.mysql.com/downloads/connector/c/
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.0.2-win32.msi/from/http://ftp.jaist.ac.jp/pub/mysql/
2.并修改MySQL-python-1.2.5 包内的 site.cfg内容:
将connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2 改为x64系统下mysql-connector-c 库的安装路径:
如:connector = C:\Program Files\MySQL\MySQL Connector C 6.0.2
就可以成功安装 MySQL-python-1.2.5。
另外由mysql提供的纯python库
mysql-connector-python,下载:http://dev.mysql.com/downloads/connector/python/,该库为纯python库,无需额外安装库 就可操作mysql,通用性更好,但执行效率低于mysqldb。
参考:
Python MySQLdb vs mysql-connector query performance
sqlAlchemy speed tests on mysql-connector-python, mysqldb and oursql drivers
http://blog.fizyk.net.pl/blog/sqlalchemy-speed-tests-on-mysql-connector-python-mysqldb-and-oursql-drivers.html
阅读(1226) | 评论(0) | 转发(0) |