a connection. This is typically delivered using the ``charset`` parameter
in the URL, such as::
- e = create_engine("mysql+pymysql://scott:tiger@localhost/test?charset=utf8")
+ e = create_engine(
+ "mysql+pymysql://scott:tiger@localhost/test?charset=utf8")
This charset is the **client character set** for the connection. Some
MySQL DBAPIs will default this to a value such as ``latin1``, and some
this new charset is preferred, if supported by both the database as well
as the client DBAPI, as in::
- e = create_engine("mysql+pymysql://scott:tiger@localhost/test?charset=utf8mb4")
+ e = create_engine(
+ "mysql+pymysql://scott:tiger@localhost/test?charset=utf8mb4")
At the moment, up-to-date versions of MySQLdb and PyMySQL support the
``utf8mb4`` charset. Other DBAPIs such as MySQL-Connector and OurSQL
.. seealso::
`The utf8mb4 Character Set \
-<http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html>`_ - \
-in the MySQL documentation
+ <http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html>`_ - \
+ in the MySQL documentation
Unicode Encoding / Decoding
~~~~~~~~~~~~~~~~~~~~~~~~~~~
``str`` type or ``bytes`` type, with data in the configured charset::
# connect while disabling the DBAPI's unicode encoding/decoding
- e = create_engine("mysql+mysqldb://scott:tiger@localhost/test?charset=utf8&use_unicode=0")
+ e = create_engine(
+ "mysql+mysqldb://scott:tiger@localhost/test?charset=utf8&use_unicode=0")
Current recommendations for modern DBAPIs are as follows:
.. seealso::
- `CREATE INDEX <http://dev.mysql.com/doc/refman/5.0/en/create-index.html>`_ - MySQL documentation
+ `CREATE INDEX <http://dev.mysql.com/doc/refman/5.0/en/create-index.html>`_ - \
+ MySQL documentation
Index Types
~~~~~~~~~~~~~