Is there some methods like 'datareader' in MySQLdb for handling mass data
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Tue Jan 6 06:29:49 EST 2009
Jeremy.Chen a écrit :
> hi all:
> when I handled mass data table in mysql with python's MySQLdb lib,
> something frustrated me. I could't find any function like datareader,
> which yield one row by recording rows' anchor ,after each time I
> invoked 'read()' in a loop.
I think you want cursor.fetchone(). But read below...
> fetchall or fetchmany just fetched all data
> in once, which take so much memory when meeting one mass data
> table.
The cursor object is it's own iterator. So you just have to do:
cursor.execute(your_query)
for row in cursor:
process(row)
HTH
More information about the Python-list
mailing list