I just had a discussion today with some coworkers about python\'s db-api fetchone vs fetchmany vs fetchall.
I\'m sure the use case for each of these is dependent on
These are implementation specific.
Will get all the results from the table. This will work better when size of the table is small. If the table size is bigger, fetchall will fail in those cases.
Will use most of the memory.
Will cause some issues will can occur if the queries is done on network.
fetchmany will get only required number of results. You can yield the results and process. Simple Snippet of implementation of fetchmany.
while True:
results = cursor.fetchmany(arraysize)
if not results:
break
for result in results:
yield result