From: Jay Freeman (saurik) Date: Mon, 28 Nov 2011 12:16:00 +0000 (+0000) Subject: Switch to psycopg2 autocommit syntax. X-Git-Url: https://git.saurik.com/cyql.git/commitdiff_plain/f392523d5d61f3447a05a319ec2e703dcc7a9596 Switch to psycopg2 autocommit syntax. --- diff --git a/__init__.py b/__init__.py index 6ce111e..9fc8d31 100644 --- a/__init__.py +++ b/__init__.py @@ -31,7 +31,7 @@ class connect(object): try: self.driver.set_client_encoding('UNICODE') - self.driver.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) + self.driver.autocommit = True except: self.driver.close() @@ -50,7 +50,7 @@ class connect(object): self.close() def begin(self): - self.driver.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED) + self.driver.autocommit = False def commit(self): self.driver.commit() @@ -117,7 +117,7 @@ class connect(object): @contextmanager def transact(self, synchronous_commit=True): - self.driver.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED) + self.driver.autocommit = False try: with self.cursor() as cursor: if not synchronous_commit: @@ -129,7 +129,7 @@ class connect(object): self.driver.rollback() raise finally: - self.driver.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) + self.driver.autocommit = True def one_(self, statement, context=None): with self.execute(statement, 2, context) as cursor: