Skip to content

Commit

Permalink
Also fix executemany().
Browse files Browse the repository at this point in the history
  • Loading branch information
gbandet committed Nov 5, 2013
1 parent 8bef335 commit 8096d8c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion MySQLdb/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,13 @@ def executemany(self, query, args):
e = m.end(1)
qv = m.group(1)
try:
q = [ qv % db.literal(a) for a in args ]
q = []
for a in args:
if isinstance(a, dict):
q.append(qv % dict((key, db.literal(item))
for key, item in a.iteritems()))
else:
q.append(qv % tuple([db.literal(item) for item in a]))
except TypeError, msg:
if msg.args[0] in ("not enough arguments for format string",
"not all arguments converted"):
Expand Down

0 comments on commit 8096d8c

Please sign in to comment.