Commit 7c302c3c authored by Denis Bilenko's avatar Denis Bilenko

examples/psycopg2_pool.py: make it possible to pass arguments to cursor() in...

examples/psycopg2_pool.py: make it possible to pass arguments to cursor() in execute() and fetch*() methods
parent 823160b4
......@@ -107,23 +107,23 @@ class DatabaseConnectionPool(object):
return conn
def execute(self, *args, **kwargs):
with self.cursor() as cursor:
cursor.execute(*args, **kwargs)
with self.cursor(**kwargs) as cursor:
cursor.execute(*args)
return cursor.rowcount
def fetchone(self, *args, **kwargs):
with self.cursor() as cursor:
cursor.execute(*args, **kwargs)
with self.cursor(**kwargs) as cursor:
cursor.execute(*args)
return cursor.fetchone()
def fetchall(self, *args, **kwargs):
with self.cursor() as cursor:
cursor.execute(*args, **kwargs)
with self.cursor(**kwargs) as cursor:
cursor.execute(*args)
return cursor.fetchall()
def fetchiter(self, *args, **kwargs):
with self.cursor() as cursor:
cursor.execute(*args, **kwargs)
with self.cursor(**kwargs) as cursor:
cursor.execute(*args)
while True:
items = cursor.fetchmany()
if not items:
......
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