summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/schema.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends/mysql/schema.py')
-rw-r--r--django/db/backends/mysql/schema.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/db/backends/mysql/schema.py b/django/db/backends/mysql/schema.py
index 997fef1c0c..f969e6e4d8 100644
--- a/django/db/backends/mysql/schema.py
+++ b/django/db/backends/mysql/schema.py
@@ -25,9 +25,11 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_delete_pk = "ALTER TABLE %(table)s DROP PRIMARY KEY"
def quote_value(self, value):
- # Inner import to allow module to fail to load gracefully
- import MySQLdb.converters
- return MySQLdb.escape(value, MySQLdb.converters.conversions)
+ self.connection.ensure_connection()
+ quoted = self.connection.connection.escape(value, self.connection.connection.encoders)
+ if isinstance(value, str):
+ quoted = quoted.decode()
+ return quoted
def _is_limited_data_type(self, field):
db_type = field.db_type(self.connection)