I recently had a discussion with some co-workers about python db-api fetchone vs fetchmany vs fetchall.
I am sure that the use case for each of them depends on the db-api implementation that I use, but in general, what are the use cases for fetchone vs fetchmany vs fetchall?
In other words, the next equivalent? or is there one of them that is preferable to others? and if so, in what situations?
cursor.execute("SELECT id, name FROM `table`") for i in xrange(cursor.rowcount): id, name = cursor.fetchone() print id, name cursor.execute("SELECT id, name FROM `table`") result = cursor.fetchmany() while result: for id, name in result: print id, name result = cursor.fetchmany() cursor.execute("SELECT id, name FROM `table`") for id, name in cursor.fetchall(): print id, name
python mysql python-db-api
Alex Q Mar 04 '11 at 5:18 2011-03-04 05:18
source share