python 操作python

#!/usr/bin/env python
#_*_ coding:utf-8 _*_

import MySQLdb

# 打开门
conn = MySQLdb.connect(host='192.168.1.21',user='yangqw',passwd='1',db='free')

# 伸出手
cur = conn.cursor()

# 对数据进行操作
reCount= cur.execute('select * from student')
data = cur.fetchall()

# 伸回手
cur.close()

# 关上门
conn.close()

print reCount
print data

posted @ 2017-08-08 01:14  有肉的三明治  阅读(237)  评论(0编辑  收藏  举报