diff options
author | farcepest <farcepest@gmail.com> | 2012-10-05 14:01:51 -0400 |
---|---|---|
committer | farcepest <farcepest@gmail.com> | 2012-10-05 14:01:51 -0400 |
commit | 7d4993a53c9706b697d60b61544d7d2047a1667f (patch) | |
tree | be4b4e749f122b26bfcf4195b7ed8aad3d4014ef /MySQLdb | |
parent | f982ab42f5deb8bf9aec3377a0571590c9c98d7f (diff) | |
download | mysqldb1-7d4993a53c9706b697d60b61544d7d2047a1667f.tar.gz |
Workaround for recommended MySQL 5.5 utf8mb4 character set, which is not recognized by Python yet.
Diffstat (limited to 'MySQLdb')
-rw-r--r-- | MySQLdb/connections.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index 1d6fa82..27de110 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -289,6 +289,10 @@ class Connection(_mysql.connection): set can only be changed in MySQL-4.1 and newer. If you try to change the character set from the current value in an older version, NotSupportedError will be raised.""" + if charset == "utf8mb4": + py_charset = "utf8" + else: + py_charset = charset if self.character_set_name() != charset: try: super(Connection, self).set_character_set(charset) @@ -297,8 +301,8 @@ class Connection(_mysql.connection): raise NotSupportedError("server is too old to set charset") self.query('SET NAMES %s' % charset) self.store_result() - self.string_decoder.charset = charset - self.unicode_literal.charset = charset + self.string_decoder.charset = py_charset + self.unicode_literal.charset = py_charset def set_sql_mode(self, sql_mode): """Set the connection sql_mode. See MySQL documentation for |