From 4e7c3d50deea68319c9622a4fd4af5126567cffe Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 11 Jan 2007 00:27:45 +0000 Subject: [PATCH] - added "fetchmany()" support to ResultProxy --- CHANGES | 1 + lib/sqlalchemy/engine/base.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGES b/CHANGES index 99d1316fad..ad4c72f422 100644 --- a/CHANGES +++ b/CHANGES @@ -8,6 +8,7 @@ - postgres no longer uses client-side cursors, uses more efficient server side cursors via apparently undocumented psycopg2 behavior recently discovered on the mailing list. disable it via create_engine('postgres://', client_side_cursors=True) + - added "fetchmany()" support to ResultProxy - added "BIGSERIAL" support for postgres table with PGBigInteger/autoincrement - fixes to postgres reflection to better handle when schema names are present; thanks to jason (at) ncsmags.com [ticket:402] diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 7fcf52af6d..65f2b5586b 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -676,6 +676,19 @@ class ResultProxy(object): self.close() return l + def fetchmany(self, size=None): + """fetch many rows, juts like DBAPI cursor.fetchmany(size=cursor.arraysize)""" + if size is None: + rows = self.cursor.fetchmany() + else: + rows = self.cursor.fetchmany(size=size) + l = [] + for row in rows: + l.append(RowProxy(self, row)) + if len(l) == 0: + self.close() + return l + def fetchone(self): """fetch one row, just like DBAPI cursor.fetchone().""" row = self.cursor.fetchone() -- 2.47.2