How to get a row-by-row MySQL ResultSet in python

I think you have to connect passing cursorclass = MySQLdb.cursors.SSCursor:

 MySQLdb.connect(user="user", 
                 passwd="password",
                 db="mydb",
                 cursorclass = MySQLdb.cursors.SSCursor
                )

The default cursor fetches all the data at once, even if you don’t use fetchall.

Edit: SSCursor or any other cursor class that supports server side resultsets – check the module docs on MySQLdb.cursors.

Leave a Comment