From bffe10fe95c6d052872bb3dcf3397bedc199db4c Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 28 Nov 2011 10:35:34 +0000 Subject: [PATCH] Add features to support database.py. --- __init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index 2123108..6ce111e 100644 --- a/__init__.py +++ b/__init__.py @@ -49,6 +49,15 @@ class connect(object): def __exit__(self, type, value, traceback): self.close() + def begin(self): + self.driver.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED) + + def commit(self): + self.driver.commit() + + def rollback(self): + self.driver.rollback() + @contextmanager def cursor(self): cursor = self.driver.cursor(cursor_factory=psycopg2.extras.DictCursor) @@ -144,8 +153,8 @@ class connect(object): with self.execute(statement, 1) as cursor: yield cursor - def all(self, statement): - with self.execute(statement, 1) as cursor: + def all(self, statement, context=None): + with self.execute(statement, 1, context) as cursor: return cursor.fetchall() def one(self, statement, context=None): -- 2.47.2