我同意Otto Allmendinger的回答,但是要做出明确的Denis
Otkidach的评论,这是不使用Otto的fetch()函数即可遍历结果的方法:
import MySQLdb.cursorsconnection=MySQLdb.connect( host="thehost",user="theuser", passwd="thepassword",db="thedb", cursorclass = MySQLdb.cursors.SSCursor)cursor=connection.cursor()cursor.execute(query)for row in cursor: print(row)



