From 4e7c3d50deea68319c9622a4fd4af5126567cffe Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 11 Jan 2007 00:27:45 +0000 Subject: - added "fetchmany()" support to ResultProxy --- lib/sqlalchemy/engine/base.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/sqlalchemy/engine/base.py') 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() -- cgit v1.2.1