]> git.saurik.com Git - cyql.git/commitdiff
Add exists(), refactoring yank() to take an argument for offset (required as a utility).
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 30 Jul 2010 07:21:07 +0000 (07:21 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 30 Jul 2010 07:21:07 +0000 (07:21 +0000)
__init__.py

index 2bddbe4a0afbf6dbb2fb3c6af948d938d670786d..bda044b8a11115e05b70b325c450c13dc6a051f3 100644 (file)
@@ -56,8 +56,8 @@ class transaction(object):
         with self.connection.execute(statement, 1) as cursor:
             return cursor.fetchall()
 
-    def yank(self, statement):
-        with self.connection.execute(statement, 1) as cursor:
+    def yank(self, statement, offset=0):
+        with self.connection.execute(statement, 1 + offset) as cursor:
             rows = cursor.fetchall()
             return rows[0] if len(rows) != 0 else None
 
@@ -65,6 +65,13 @@ class transaction(object):
         with self.connection.execute(statement, 1) as cursor:
             pass
 
+    def exists(self, statement):
+        return yank('''
+            select exists (
+                {statement}
+            )
+        ''')[0]
+
 @contextmanager
 def connect(dsn):
     attempt = 0