1. 安装Eclipse Juno
http://www.eclipse.org/downloads/
2. 安装Mysql 5.5
http://www.mysql.com
3. 安装Mysql客户端Navicat
http://www.navicat.com/
4. 为Eclipse安装Python插件Pydev
http://pydev.org/, update site:
http://pydev.org/updates
5. 安装PyMysql
https://github.com/petehunt/PyMySQL/
6. 创建数据库db, 创建history表,插入数据
7. 创建Python项目,编写代码
import pymysql
conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='', db='db')
cur = conn.cursor()
cur.execute("SELECT * FROM history")
for r in cur.fetchall():
print(r)
cur.close()
conn.close()
8. 访问成功!