From fce82ca2931fa62798d6cb70037689920752bf96 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 13 Jan 2011 06:03:13 +0000 Subject: [PATCH] Generalize context as argument to execute(). --- __init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index 9448695..8ac73cf 100644 --- a/__init__.py +++ b/__init__.py @@ -31,12 +31,14 @@ class connection(object): yield cursor @contextmanager - def execute(self, statement, depth=0): + def execute(self, statement, depth=0, context=None): with self.cursor() as cursor: # two frames, accounting for execute() and @contextmanager locals = inspect.currentframe(depth + 2).f_locals try: - cursor.execute(statement.format(**locals), locals) + if context == None: + context = locals + cursor.execute(statement.format(**locals), context) finally: del locals yield cursor -- 2.47.2