summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py10
-rw-r--r--lib/sqlalchemy/dialects/mysql/mysqldb.py12
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 8933e0b70..5647c38f2 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -3298,9 +3298,17 @@ class _DecodingRowProxy(object):
# sets.Set(['value']) (seriously) but thankfully that doesn't
# seem to come up in DDL queries.
+ _encoding_compat = {
+ 'koi8r': 'koi8_r',
+ 'koi8u': 'koi8_u',
+ 'utf16': 'utf-16-be', # MySQL's uft16 is always bigendian
+ 'utf8mb4': 'utf8', # real utf8
+ 'eucjpms': 'ujis',
+ }
+
def __init__(self, rowproxy, charset):
self.rowproxy = rowproxy
- self.charset = charset
+ self.charset = self._encoding_compat.get(charset, charset)
def __getitem__(self, index):
item = self.rowproxy[index]
diff --git a/lib/sqlalchemy/dialects/mysql/mysqldb.py b/lib/sqlalchemy/dialects/mysql/mysqldb.py
index 0d125a245..a65f69622 100644
--- a/lib/sqlalchemy/dialects/mysql/mysqldb.py
+++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py
@@ -28,6 +28,18 @@ unicode** will include both charset and use_unicode=0::
create_engine("mysql+mysqldb://user:pass@host/dbname?charset=utf8&use_unicode=0")
+For MySQL versions 5.5.3 and MySQLdb version 1.2.3 forward, the special
+MySQL-specific encoding 'utf8mb4' is now recommended::
+
+ create_engine("mysql+mysqldb://user:pass@host/dbname?charset=utf8mb4&use_unicode=0")
+
+The 'utf8' encoding may still be used, however MySQL will only support
+unicode characters within the first three of four possible bytes:
+no (💩 or 😻) note that in order to use utf8mb4 fully, changes to
+the MySQL schema and/or server configuration may be required.
+See also: `The utf8mb4 character set
+<http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html>_`.
+
As of this writing, MySQLdb only runs on Python 2. It is not known how
MySQLdb behaves on Python 3 as far as unicode decoding.