summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2017-09-18 09:49:50 -0400
committerGerrit Code Review <gerrit@awstats.zzzcomputing.com>2017-09-18 09:49:50 -0400
commit08430e689f1a0190f671636016b12ff2ca08531f (patch)
tree76c733bfdef11507e08bcdc4dd2066071942f085 /lib/sqlalchemy
parentaed2324b4de3c4f3e6cc7f801fc8ddd8e2d9012b (diff)
parent339416b821ed543f289fccff8f6fc9c44dbc9d23 (diff)
downloadsqlalchemy-08430e689f1a0190f671636016b12ff2ca08531f.tar.gz
Merge "Add __next__(), next() to ResultProxy"
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/engine/result.py16
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.