Review Request of Python Code

INADA Naoki songofacandy at gmail.com
Wed Mar 9 02:52:41 EST 2016


While MySQL doesn't have server side cursor, MySQLdb has SSCursor class.
https://github.com/PyMySQL/mysqlclient-python/blob/master/MySQLdb/cursors.py#L551

Default cursor fetches MySQL response at once and convert them into Python
object.
SSCursor fetches MySQL response row by row.  So it saves Python memory
consumption (and
MySQL server can't release some resource until client fetches all rows.)

To use SScursor:

    cur = db.cursor()
>

cur = db.cursor(MySQLdb.cursors.SSCursor)

    for row in cur.fetchall():
>

for row in cur:

-- 
INADA Naoki  <songofacandy at gmail.com>



More information about the Python-list mailing list