summaryrefslogtreecommitdiff
path: root/MySQLdb/cursors.py
diff options
context:
space:
mode:
Diffstat (limited to 'MySQLdb/cursors.py')
-rw-r--r--MySQLdb/cursors.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py
index 7e5a887..7c01870 100644
--- a/MySQLdb/cursors.py
+++ b/MySQLdb/cursors.py
@@ -180,7 +180,11 @@ class BaseCursor(object):
if isinstance(query, unicode):
query = query.encode(db.unicode_literal.charset)
if args is not None:
- query = query % db.literal(args)
+ if isinstance(args, dict):
+ query = query % dict((key, db.literal(item))
+ for key, item in args.iteritems())
+ else:
+ query = query % tuple([db.literal(item) for item in args])
try:
r = None
r = self._query(query)
@@ -236,7 +240,13 @@ class BaseCursor(object):
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"):