Commit 8dff8b7a authored by Denis Bilenko's avatar Denis Bilenko

examples/psycopg2_pool.py: add fetchall() and fetchiter() methods

parent a7b9618b
......@@ -116,6 +116,21 @@ class DatabaseConnectionPool(object):
cursor.execute(*args, **kwargs)
return cursor.fetchone()
def fetchall(self, *args, **kwargs):
with self.cursor() as cursor:
cursor.execute(*args, **kwargs)
return cursor.fetchall()
def fetchiter(self, *args, **kwargs):
with self.cursor() as cursor:
cursor.execute(*args, **kwargs)
while True:
items = cursor.fetchmany()
if not items:
break
for item in items:
yield item
class PostgresConnectionPool(DatabaseConnectionPool):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment