db=MySQLdb.connect(host=’localhost’,user=’root’, passwd=’xxxxx’,db=’dbname’)
cur=db.cursor()
cur.execute(‘select * from records’)
打印所有执行结果
rs=cur.fetchall()
for r in rs:
print r
打印一条数据的所有字段信息
rs=cur.fetchone()
for r in range(1,n):
print list(rs)[i]