]> git.saurik.com Git - cyql.git/commitdiff
Switch to psycopg2 autocommit syntax.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 28 Nov 2011 12:16:00 +0000 (12:16 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 28 Nov 2011 12:16:00 +0000 (12:16 +0000)
__init__.py

index 6ce111ef57ecef011ce497a5ab55bfe5d007f7c5..9fc8d31c388bea89919ee55c414d99311c962b24 100644 (file)
@@ -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: