Is there some methods like 'datareader' in MySQLdb for handling massdata

J

Jeremy.Chen

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.fetchall or fetchmany just fetched all data
in once, which take so much memory when meeting one mass data
table.
Is anybody know that function or other lib similar to MySQLdb ?
thanks!
 
B

Bruno Desthuilliers

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
 
J

Jeremy.Chen

Jeremy.Chen a écrit :


I think you want cursor.fetchone(). But read below...


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

That's what I want.
I see,cursor also can be a iterator.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top