[Sqlalchemy-commits] commit/sqlalchemy: malor: Add support for server side cursors to mysqldb and p
Brought to you by:
zzzeek
From: Bitbucket <com...@bi...> - 2016-11-10 19:50:05
|
1 new commit in sqlalchemy: https://bitbucket.org/zzzeek/sqlalchemy/commits/d1e31ab1582e/ Changeset: d1e31ab1582e Branch: master User: malor Date: 2016-11-10 17:09:27+00:00 Summary: Add support for server side cursors to mysqldb and pymysql This allows to skip buffering of the results on the client side, e.g. the following snippet: table = sa.Table( 'testtbl', sa.MetaData(), sa.Column('id', sa.Integer, primary_key=True), sa.Column('a', sa.Integer), sa.Column('b', sa.String(512)) ) table.create(eng, checkfirst=True) with eng.connect() as conn: result = conn.execute(table.select().limit(1)).fetchone() if result is None: for _ in range(1000): conn.execute( table.insert(), [{'a': random.randint(1, 100000), 'b': ''.join(random.choice(string.ascii_letters) for _ in range(100))} for _ in range(1000)] ) with eng.connect() as conn: for row in conn.execution_options(stream_results=True).execute(table.select()): pass now uses ~23 MB of memory instead of ~327 MB on CPython 3.5.2 and PyMySQL 0.7.9. psycopg2 implementation and execution options (stream_results, server_side_cursors) are reused. Change-Id: I4dc23ce3094f027bdff51b896b050361991c62e2 Affected #: 11 files Repository URL: https://bitbucket.org/zzzeek/sqlalchemy/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |