- # coding=utf-8
- import MySQLdb
- import sys
- conn = MySQLdb.connect(host="localhost", user="root", passwd="root", db="blog", charset="utf8")
- cursor = conn.cursor()
- cursor.execute("select * from user")
- records = cursor.fetchall()
- for row in records:
- for r in row:
- print r
- #该片段来自于http://www.codesnippet.cn/detail/230920136072.html
来源: http://www.codesnippet.cn/detail/230920136072.html