From: Jay Freeman (saurik) Date: Tue, 11 Jan 2011 02:27:20 +0000 (+0000) Subject: Add execute_() and push_() that take a manual locals. X-Git-Url: https://git.saurik.com/cyql.git/commitdiff_plain/3de15e7bc2f2b4e42050cf4ca55135d2ac1bd14f Add execute_() and push_() that take a manual locals. --- diff --git a/__init__.py b/__init__.py index 10383d3..9448695 100644 --- a/__init__.py +++ b/__init__.py @@ -24,6 +24,12 @@ class connection(object): finally: cursor.close() + @contextmanager + def execute_(self, statement, locals): + with self.cursor() as cursor: + cursor.execute(statement.format(**locals), locals) + yield cursor + @contextmanager def execute(self, statement, depth=0): with self.cursor() as cursor: @@ -65,6 +71,10 @@ class transaction(object): with self.connection.execute(statement, 1) as cursor: pass + def push_(self, statement, locals): + with self.connection.execute_(statement, locals) as cursor: + pass + def exists(self, statement): return self.yank(''' select exists (