1.安装mysql(略)
2.安装pymysql(python3版本)
附了安装包,安装步骤简单,在此省略啦
3.安装成功后进入dos界面,输入:pip install mysqlclient-1.3.12-cp36-cp36m-win_amd64.whl
4.输入import pymysql不报错说明成功一大半啦
5.下面就可以连接数据库啦
代码:
#encoding=utf-8 import pymysql conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='1122!!',db='test') cur = conn.cursor() cur.execute("SELECT c.nick_name ,v.vendor_num,v.vendor_model FROM vendor v,cover c WHERE v.vendor_model = '100'") for r in cur.fetchall(): print(r) cur.close() conn.close()
6.哇 成功~~bling