Created
April 10, 2017 20:44
-
-
Save rectalogic/ba7aa8475a59f404469cad07baad8181 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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