python之MySQLdb实操测试
调试费了一些周折,但还是成功了,摸索中前进比较难,处处是坑。import MySQLdb
db = MySQLdb.connect(host='127.0.0.1',user='root',passwd='pawwd',db='db',charset='gbk')
cur = db.cursor()
cur.execute("select * from user_info")
#res = cur.fetchall()
res = cur.fetchone()
print(res)
while res:
print res
res = cur.fetchone()
db.close()