diff options
Diffstat (limited to 'lib/sqlalchemy/engine/result.py')
-rw-r--r-- | lib/sqlalchemy/engine/result.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/result.py b/lib/sqlalchemy/engine/result.py index 3aae932f2..79f362500 100644 --- a/lib/sqlalchemy/engine/result.py +++ b/lib/sqlalchemy/engine/result.py @@ -862,6 +862,8 @@ class ResultProxy(object): self.closed = True def __iter__(self): + """Implement iteration protocol.""" + while True: row = self.fetchone() if row is None: @@ -869,6 +871,20 @@ class ResultProxy(object): else: yield row + def __next__(self): + """Implement the next() protocol. + + .. versionadded:: 1.2 + + """ + row = self.fetchone() + if row is None: + raise StopIteration() + else: + return row + + next = __next__ + @util.memoized_property def inserted_primary_key(self): """Return the primary key for the row just inserted. |