Skip to content

Instantly share code, notes, and snippets.

@rectalogic
Created April 10, 2017 20:44
Show Gist options
  • Select an option

  • Save rectalogic/ba7aa8475a59f404469cad07baad8181 to your computer and use it in GitHub Desktop.

Select an option

Save rectalogic/ba7aa8475a59f404469cad07baad8181 to your computer and use it in GitHub Desktop.
def stream(q):
def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
cursor.scrollable = True
with sql.rds_engine.engine.connect() as conn:
streamconn = conn.execution_options(stream_results=True)
sa.event.listen(streamconn, "before_cursor_execute", before_cursor_execute)
results = streamconn.execute(q)
print "rowcount", results.rowcount
r = conn.execute("MOVE FORWARD ALL FROM {}".format(results.cursor.name))
r = conn.execute("MOVE BACKWARD ALL FROM {}".format(results.cursor.name))
print "CORRECT rowcount", r.rowcount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment