Python版本: 3.5.0html
MySqlDB官網只支持Python3.4,這裏Python3.5使用第三方庫PyMysql鏈接Mysql數據庫。python
http://dev.mysql.com/downloads/connector/python/2.0.htmlmysql
PyMysql下載地址:sql
https://pypi.python.org/pypi/PyMySQL#downloads數據庫
Windows下安裝方法:測試
下載解壓後,進入PyMySql-0.6.7目錄,執行python setup.py install安裝 spa
簡單測試:code
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()
執行結果:htm
('5.6.23-enterprise-commercial-advanced-log',)blog