当生成大量结果集时,典型的MySQLdb库查询会使用大量内存并且在Python中执行不佳。例如:cursor.execute("SELECTid,nameFROM`table`")foriinxrange(cursor.rowcount):id,name=cursor.fetchone()printid,name有一个可选的游标,一次只能获取一行,这确实加快了脚本的速度并大大减少了脚本的内存占用。importMySQLdbimportMySQLdb.cursorsconn=MySQLdb.connect(user="user",passwd="password",db="dbname"