From: Mike Bayer Date: Thu, 11 Jan 2007 00:27:45 +0000 (+0000) Subject: - added "fetchmany()" support to ResultProxy X-Git-Tag: rel_0_3_4~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e7c3d50deea68319c9622a4fd4af5126567cffe;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - added "fetchmany()" support to ResultProxy --- 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()