]> git.saurik.com Git - cyql.git/commitdiff
Add global cyq.transact() helper to make single transaction connections simpler.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 12 May 2010 12:52:31 +0000 (12:52 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 12 May 2010 12:52:31 +0000 (12:52 +0000)
__init__.py

index 00a4573ecb89212cd8031cc43a340d1b90b68628..0c29a582215770b31c8ed2cffdc820e5fa49c525 100644 (file)
@@ -80,6 +80,12 @@ def connect(dsn):
     finally:
         driver.close()
 
     finally:
         driver.close()
 
+@contextmanager
+def transact(dsn, **args):
+    with connect(dsn) as connection:
+        with connection.transact(**args) as cursor:
+            yield cursor
+
 """
 def slap_(sql, table, keys, values, path):
     csr = sql.cursor()
 """
 def slap_(sql, table, keys, values, path):
     csr = sql.cursor()