From b74856742485262b95796a4bb3bd3d94e7ba15bc Mon Sep 17 00:00:00 2001 From: kennethdamica Date: Tue, 10 Jun 2014 19:55:28 -0700 Subject: [PATCH] Added tuple input for execute parameters --- vertica_python/vertica/cursor.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vertica_python/vertica/cursor.py b/vertica_python/vertica/cursor.py index 0ed5dba9..3ae2152a 100644 --- a/vertica_python/vertica/cursor.py +++ b/vertica_python/vertica/cursor.py @@ -45,9 +45,15 @@ def execute(self, operation, parameters=None): if parameters: # optional requirement from psycopg2.extensions import adapt - for key in parameters: - v = adapt(parameters[key]).getquoted() - operation = operation.replace(':' + key, v) + + if isinstance(parameters, dict): + for key in parameters: + v = adapt(parameters[key]).getquoted() + operation = operation.replace(':' + key, v) + elif isinstance(parameters, tuple): + operation = operation % tuple(adapt(p).getquoted() for p in parameters) + else: + raise errors.Error("Argument 'parameters' must be dict or tuple") self.rowcount = 0 self.buffered_rows = collections.deque()