Python版本: 3.5.0
MySqlDB官网只支持Python3.4,这里Python3.5使用第三方库PyMysql连接Mysql数据库。
http://dev.mysql.com/downloads/connector/python/2.0.html
PyMysql下载地址:
https://pypi.python.org/pypi/PyMySQL#downloads
Windows下安装方法:
下载解压后,进入PyMySql-0.6.7目录,执行python setup.py install安装
简单测试:
import pymysql conn = pymysql.connect(host='localhost', port=3306,user='root',passwd='rusky',db='mysql',charset='UTF8') cur = conn.cursor() cur.execute("select version()") for i in cur: print(i) cur.close() conn.close()
执行结果:
('5.6.23-enterprise-commercial-advanced-log',)