Skip to content

Commit

Permalink
Merge pull request #31 from kennethdamica/master
Browse files Browse the repository at this point in the history
Added tuple input for execute parameters
  • Loading branch information
alexjikim committed Jun 11, 2014
2 parents d3cd741 + b748567 commit 1a3a188
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions vertica_python/vertica/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1a3a188

Please sign in to comment.