From 57dd34dc10e3f8ec7d860dc8bc8e6baccb571b60 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Wed, 11 May 2016 15:24:36 +0900 Subject: [PATCH] fixup --- MySQLdb/connections.py | 1 - MySQLdb/cursors.py | 6 +++--- tests/test_cursor.py | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index d97e918..1f69f5c 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -65,7 +65,6 @@ def numeric_part(s): class Connection(_mysql.connection): - """MySQL Database Connection Object""" default_cursor = cursors.Cursor diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py index 6260a02..1e0a3f9 100644 --- a/MySQLdb/cursors.py +++ b/MySQLdb/cursors.py @@ -110,18 +110,18 @@ class BaseCursor(object): if isinstance(args, (tuple, list)): if PY2: args = tuple(map(ensure_bytes, args)) - return tuple(conn.escape(arg) for arg in args) + return tuple(conn.literal(arg) for arg in args) elif isinstance(args, dict): if PY2: args = dict((ensure_bytes(key), ensure_bytes(val)) for (key, val) in args.items()) - return dict((key, conn.escape(val)) for (key, val) in args.items()) + return dict((key, conn.literal(val)) for (key, val) in args.items()) else: # If it's not a dictionary let's try escaping it anyways. # Worst case it will throw a Value error if PY2: args = ensure_bytes(args) - return conn.escape(args) + return conn.literal(args) def _check_executed(self): if not self._executed: diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 04bb1c4..bfdcb33 100644 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -53,12 +53,12 @@ def test_executemany(): # list args data = range(10) cursor.executemany("insert into test (data) values (%s)", data) - assert cursor._executed.endswith(",(7),(8),(9)"), 'execute many with %s not in one query' + assert cursor._executed.endswith(b",(7),(8),(9)"), 'execute many with %s not in one query' # dict args data_dict = [{'data': i} for i in range(10)] cursor.executemany("insert into test (data) values (%(data)s)", data_dict) - assert cursor._executed.endswith(",(7),(8),(9)"), 'execute many with %(data)s not in one query' + assert cursor._executed.endswith(b",(7),(8),(9)"), 'execute many with %(data)s not in one query' # %% in column set cursor.execute("""\ @@ -69,6 +69,6 @@ def test_executemany(): q = "INSERT INTO percent_test (`A%%`, `B%%`) VALUES (%s, %s)" assert MySQLdb.cursors.RE_INSERT_VALUES.match(q) is not None cursor.executemany(q, [(3, 4), (5, 6)]) - assert cursor._executed.endswith("(3, 4),(5, 6)"), "executemany with %% not in one query" + assert cursor._executed.endswith(b"(3, 4),(5, 6)"), "executemany with %% not in one query" finally: cursor.execute("DROP TABLE IF EXISTS percent_test")