diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-01-11 00:27:45 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-01-11 00:27:45 +0000 |
| commit | 4e7c3d50deea68319c9622a4fd4af5126567cffe (patch) | |
| tree | 39227338a4a26f09c4bab53c147d6f1e2003b3dd | |
| parent | ba3ebe44dec08fa74363d63a19ddc2b2782f3350 (diff) | |
| download | sqlalchemy-4e7c3d50deea68319c9622a4fd4af5126567cffe.tar.gz | |
- added "fetchmany()" support to ResultProxy
| -rw-r--r-- | CHANGES | 1 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 13 |
2 files changed, 14 insertions, 0 deletions
@@ -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 7fcf52af6..65f2b5586 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() |
