From 171d335b8a9673a745f11d622163c467ab035d24 Mon Sep 17 00:00:00 2001 From: skeleton9 Date: Thu, 22 May 2014 17:30:54 +0800 Subject: [PATCH] fix string replacement support for sql string replacement was broken by https://github.com/farcepest/MySQLdb1/commit/87d1145c0d6ee4f5a8ecf6d5c62d2479b9cf27ea This fix is to bring the string replacement support back: sql = "SELECT * FROM table_name WHERE column = %s" cursor.execute(sql, 'passed_variable') --- MySQLdb/cursors.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py index 348a586a..1dc804c6 100644 --- a/MySQLdb/cursors.py +++ b/MySQLdb/cursors.py @@ -183,6 +183,8 @@ def execute(self, query, args=None): if isinstance(args, dict): query = query % dict((key, db.literal(item)) for key, item in args.iteritems()) + elif isinstance(args, str) or isinstance(args, unicode): + query = query % db.literal(args) else: query = query % tuple([db.literal(item) for item in args]) try: