diff options
author | Evax Software <contact@evax.fr> | 2012-10-08 17:25:14 +0200 |
---|---|---|
committer | Evax Software <contact@evax.fr> | 2012-10-08 17:25:14 +0200 |
commit | 9eb906e8a7ef92e1523dc65a85978130cced7e20 (patch) | |
tree | af7a3b34945f42bcc3e16258171c0c061858e6f1 /MySQLdb/cursors.py | |
parent | 7d4993a53c9706b697d60b61544d7d2047a1667f (diff) | |
download | mysqldb1-9eb906e8a7ef92e1523dc65a85978130cced7e20.tar.gz |
Map utf8mb4 to utf8 in python
Diffstat (limited to 'MySQLdb/cursors.py')
-rw-r--r-- | MySQLdb/cursors.py | 7 |
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: |