title: How to query sqlalchemy in chunks?
body: <p>How does sqlalchemy handle buffering/chunking? </p>
  
  <pre><code>with open('out', 'w') as f: 
      query = table.select()
      for row in engine.execute(query): 
          output_row = make_row_string(row)
          print(output_row, file=f)
  </code></pre>
  
  <p>Reading from the <a href="http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.ResultProxy" rel="nofollow noreferrer">ResultProxy docs</a> I infer (correctly?) that it's processing the rows all at once when they're all available. How can I query and process in chunks to make this job faster for a many-row query?</p>
  
  <p>The two ideas I have for dealing with a many-row query are <code>.fetchmany(chunksize) while True</code>, or <code>itertools</code> chunks. What is the recommended way to get many rows from a remote database?</p>