The mysqlclient DBAPI is a maintained fork of the MySQL-Python DBAPI that is no longer maintained. mysqlclient supports Python 2 and Python 3 and is very stable.
Please see :ref:`mysql_unicode` for current recommendations on unicode handling.
The mysqlclient and PyMySQL DBAPIs accept an additional dictionary under the key "ssl", which may be specified using the :paramref:`_sa.create_engine.connect_args` dictionary:
engine = create_engine( "mysql+mysqldb://scott:tiger@192.168.0.134/test", connect_args={ "ssl": { "ssl_ca": "/home/gord/client-ssl/ca.pem", "ssl_cert": "/home/gord/client-ssl/client-cert.pem", "ssl_key": "/home/gord/client-ssl/client-key.pem" } } )
For convenience, the following keys may also be specified inline within the URL where they will be interpreted into the "ssl" dictionary automatically: "ssl_ca", "ssl_cert", "ssl_key", "ssl_capath", "ssl_cipher", "ssl_check_hostname". An example is as follows:
connection_uri = ( "mysql+mysqldb://scott:tiger@192.168.0.134/test" "?ssl_ca=/home/gord/client-ssl/ca.pem" "&ssl_cert=/home/gord/client-ssl/client-cert.pem" "&ssl_key=/home/gord/client-ssl/client-key.pem" )
If the server uses an automatically-generated certificate that is self-signed or does not match the host name (as seen from the client), it may also be necessary to indicate ssl_check_hostname=false:
connection_uri = ( "mysql+pymysql://scott:tiger@192.168.0.134/test" "?ssl_ca=/home/gord/client-ssl/ca.pem" "&ssl_cert=/home/gord/client-ssl/client-cert.pem" "&ssl_key=/home/gord/client-ssl/client-key.pem" "&ssl_check_hostname=false" )
See Also
:ref:`pymysql_ssl` in the PyMySQL dialect
Google Cloud SQL now recommends use of the MySQLdb dialect. Connect using a URL like the following:
mysql+mysqldb://root@/<dbname>?unix_socket=/cloudsql/<projectid>:<instancename>
The mysqldb dialect supports server-side cursors. See :ref:`mysql_ss_cursors`.
Class | MySQLCompiler_mysqldb |
Undocumented |
Class | MySQLDialect_mysqldb |
No class docstring; 0/1 property, 0/1 instance variable, 0/8 class variable, 1/11 method, 0/1 class method documented |
Class | MySQLExecutionContext_mysqldb |
Undocumented |