summaryrefslogtreecommitdiff
path: root/MySQLdb
diff options
context:
space:
mode:
authorEvax Software <contact@evax.fr>2012-10-08 17:25:14 +0200
committerEvax Software <contact@evax.fr>2012-10-08 17:25:14 +0200
commit9eb906e8a7ef92e1523dc65a85978130cced7e20 (patch)
treeaf7a3b34945f42bcc3e16258171c0c061858e6f1 /MySQLdb
parent7d4993a53c9706b697d60b61544d7d2047a1667f (diff)
downloadmysqldb1-9eb906e8a7ef92e1523dc65a85978130cced7e20.tar.gz
Map utf8mb4 to utf8 in python
Diffstat (limited to 'MySQLdb')
-rw-r--r--MySQLdb/cursors.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py
index a8cfa3e..3023fa3 100644
--- a/MySQLdb/cursors.py
+++ b/MySQLdb/cursors.py
@@ -47,6 +47,9 @@ from _mysql_exceptions import Warning, Error, InterfaceError, DataError, \
NotSupportedError, ProgrammingError
+def normalize_utf8mb4(charset):
+ return 'utf8' if charset == 'utf8mb4' else charset
+
class BaseCursor(object):
"""A base for Cursor classes. Useful attributes:
@@ -177,7 +180,7 @@ class BaseCursor(object):
"""
del self.messages[:]
db = self._get_db()
- charset = db.character_set_name()
+ charset = normalize_utf8mb4(db.character_set_name())
if isinstance(query, unicode):
query = query.encode(charset)
if args is not None:
@@ -225,7 +228,7 @@ class BaseCursor(object):
del self.messages[:]
db = self._get_db()
if not args: return
- charset = db.character_set_name()
+ charset = normalize_utf8mb4(db.character_set_name())
if isinstance(query, unicode): query = query.encode(charset)
m = insert_values.search(query)
if not m: