From 3de15e7bc2f2b4e42050cf4ca55135d2ac1bd14f Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 11 Jan 2011 02:27:20 +0000 Subject: [PATCH] Add execute_() and push_() that take a manual locals. --- __init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 ( -- 2.50.0