Python——连接mysql

2017-01-11 15:23:24来源:oschina作者:小手冰凉丶人点击

window环境下,下载pymysql ,cmd进去PyMySQL-master目录下, 控制台输入python setup.py install 按回车安装完成后


#!C:/Users/ss/AppData/Local/Programs/Python/Python36/python.exe
# -*- coding: UTF-8 -*-
# python MYSQL
import pymysql
conn = pymysql.connect(host='localhost', user='root', passwd='123456', db='test', port=3306, charset='utf8')
cur = conn.cursor()
cur.execute("SELECT * FROM staff_info")
cur.close()
conn.close()

运行


完毕

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台