title: Best way to iterate through all rows in a DB-table
body: <p>I often write little Python scripts to iterate through all rows of a DB-table. 
  For example sending all to all subscribers a email.</p>
  
  <p>I do it like this</p>
  
  <pre><code>conn = MySQLdb.connect(host = hst, user = usr, passwd = pw, db = db)
  cursor = conn.cursor()
  subscribers = cursor.execute("SELECT * FROM tbl_subscriber;")
  
  for subscriber in subscribers:
   ...
  
  conn.close()
  </code></pre>
  
  <p>I wonder if there is a better way to do this cause it is possible that my code loads thousands of rows into the memory.</p>
  
  <p>I thought about that it could be done better with <code>LIMIT</code>.
  Maybe something like that:</p>
  
  <pre><code>"SELECT * FROM tbl_subscriber LIMIT %d,%d;" % (actualLimit,steps)    
  </code></pre>
  
  <p>Whats the best way to do it?
  How would you do it?</p>