diff options
| author | Roman Podoliaka <roman.podoliaka@gmail.com> | 2016-11-04 00:31:05 +0200 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-11-10 12:09:27 -0500 |
| commit | d1e31ab1582e2d9275c70a89b72efc2a8651df3f (patch) | |
| tree | 36518daa1d1a2468ba2d68e903b233978afbcab2 /lib/sqlalchemy/testing/requirements.py | |
| parent | 6a688b736429e27a892bc02111414491fe4103b0 (diff) | |
| download | sqlalchemy-d1e31ab1582e2d9275c70a89b72efc2a8651df3f.tar.gz | |
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
Diffstat (limited to 'lib/sqlalchemy/testing/requirements.py')
| -rw-r--r-- | lib/sqlalchemy/testing/requirements.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index af148a3b9..b001aaf75 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -288,6 +288,14 @@ class SuiteRequirements(Requirements): return exclusions.closed() @property + def server_side_cursors(self): + """Target dialect must support server side cursors.""" + + return exclusions.only_if([ + lambda config: config.db.dialect.supports_server_side_cursors + ], "no server side cursors support") + + @property def sequences(self): """Target database must support SEQUENCEs.""" |
