Python3.5链接Mysql

Python版本: 3.5.0html

MySqlDB官网只支持Python3.4,这里Python3.5使用第三方库PyMysql链接Mysql数据库。python

http://dev.mysql.com/downloads/connector/python/2.0.htmlmysql

image

PyMysql下载地址:sql

https://pypi.python.org/pypi/PyMySQL#downloads数据库

Windows下安装方法:测试

下载解压后,进入PyMySql-0.6.7目录,执行python setup.py install安装 spa

image

简单测试: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

相关文章
相关标签/搜索