编程工作肯定离不开数据库,简单展示Python连接数据库
# -*- coding:utf-8 -*-
# file: PyMySQL.py
import MySQLdb
db = MySQLdb.connect(host='localhost',user='root',passwd='unsvr2012',db='world')
cur = db.cursor()
r = cur.execute('select * from country')
r = cur.fetchall()
print r
#print coun
cur.close()
db.close()