title: Python db-api: fetchone vs fetchmany vs fetchall
body: <p>I just had a discussion today with some coworkers about python's db-api fetchone vs fetchmany vs fetchall.</p>
  
  <p>I'm sure the use case for each of these is dependent on the implementation of the db-api that I'm using, but in general what are the use cases for fetchone vs fetchmany vs fetchall?</p>
  
  <p>In other words are the following equivalent? or is there one of these that is preferred over the others? and if so in which situations?</p>
  
  <pre><code>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
  </code></pre>