From: Jay Freeman (saurik) Date: Thu, 13 Jan 2011 06:03:13 +0000 (+0000) Subject: Generalize context as argument to execute(). X-Git-Url: https://git.saurik.com/cyql.git/commitdiff_plain/fce82ca2931fa62798d6cb70037689920752bf96 Generalize context as argument to execute(). --- 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