diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-20 14:57:28 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-20 15:08:35 -0400 |
commit | 3971690731d1c22265e18ac7165a423b2310d79f (patch) | |
tree | 956b3e60cb73aa2482a3912bb75ecd2d98970918 /lib/sqlalchemy/dialects/mysql/mysqldb.py | |
parent | 58ce4d53bf5e2f2d6fa28720dc9e3a130c77f7e3 (diff) | |
download | sqlalchemy-3971690731d1c22265e18ac7165a423b2310d79f.tar.gz |
- reorganize MySQL docs re: unicode, other cleanup and updates
Diffstat (limited to 'lib/sqlalchemy/dialects/mysql/mysqldb.py')
-rw-r--r-- | lib/sqlalchemy/dialects/mysql/mysqldb.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/mysqldb.py b/lib/sqlalchemy/dialects/mysql/mysqldb.py index a65f69622..c61b09846 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqldb.py +++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py @@ -13,6 +13,7 @@ :connectstring: mysql+mysqldb://<user>:<password>@<host>[:<port>]/<dbname> :url: http://sourceforge.net/projects/mysql-python +.. _mysqldb_unicode: Unicode ------- @@ -22,26 +23,23 @@ to handle non-ASCII characters correctly. When this parameter is passed, MySQLdb will also implicitly set the "use_unicode" flag to true, which means that it will return Python unicode objects instead of bytestrings. However, SQLAlchemy's decode process, when C extensions are enabled, -is orders of magnitude faster than that of MySQLdb as it does not call into +is dramatically faster than that of MySQLdb as it does not call into Python functions to do so. Therefore, the **recommended URL to use for 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:: +The ``'utf8'`` charset on MySQL only supports **up to three-byte codepoints**, +and not four-byte codepoints as normally supported by utf8. In order to +support all unicode codepoints, MySQL versions 5.5.3 and above +provide a MySQL-specific encoding ``'utf8mb4'``, which supports +codepoints up to four bytes in size:: 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>_`. +.. seealso:: -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. + :ref:`mysql_unicode` - Includes background on the ``'utf8mb4'`` character set. Known Issues |