U ag*@sdZddlZddlmZddlmZddlmZddlmZddlmZd d lm Z d d lm Z Gd d d eZ GdddeZ GdddeZ GdddeZeZdS)a .. dialect:: mysql+mysqldb :name: mysqlclient (maintained fork of MySQL-Python) :dbapi: mysqldb :connectstring: mysql+mysqldb://:@[:]/ :url: https://pypi.org/project/mysqlclient/ Driver Status ------------- 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. .. _mysqlclient: https://github.com/PyMySQL/mysqlclient-python .. _mysqldb_unicode: Unicode ------- Please see :ref:`mysql_unicode` for current recommendations on unicode handling. .. _mysqldb_ssl: SSL Connections ---------------- 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" ) .. seealso:: :ref:`pymysql_ssl` in the PyMySQL dialect Using MySQLdb with Google Cloud SQL ----------------------------------- Google Cloud SQL now recommends use of the MySQLdb dialect. Connect using a URL like the following:: mysql+mysqldb://root@/?unix_socket=/cloudsql/: Server Side Cursors ------------------- The mysqldb dialect supports server-side cursors. See :ref:`mysql_ss_cursors`. N) MySQLCompiler) MySQLDialect)MySQLExecutionContext)MySQLIdentifierPreparer)TEXT)sql)utilc@seZdZeddZdS)MySQLExecutionContext_mysqldbcCst|dr|jS|jjSdS)N _rowcount)hasattrr cursorrowcount)selfrbC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\dialects\mysql\mysqldb.pyros z&MySQLExecutionContext_mysqldb.rowcountN)__name__ __module__ __qualname__propertyrrrrrr nsr c@s eZdZdS)MySQLCompiler_mysqldbNrrrrrrrrwsrc@s eZdZdS)MySQLIdentifierPreparer_mysqldbNrrrrrr{srcseZdZdZdZdZdZdZdZdZ e Z e Z eZfddZddZejjdd Zed d Zfd d ZddZd$ddZfddZd%ddZddZddZddZe dddd d!gZ!fd"d#Z"Z#S)&MySQLDialect_mysqldbZmysqldbTformatc s@tt|jf||jdk r6t|jdr6||jjnd|_dS)N __version__rrr)superr__init__dbapir _parse_dbapi_versionrZ_mysql_dbapi_version)rkwargs __class__rrrs zMySQLDialect_mysqldb.__init__cCs4td|}|r,tdd|dddDSdSdS)Nz(\d+)\.(\d+)(?:\.(\d+))?css|]}|dk rt|VqdSN)int).0xrrr sz.rrr)rematchtuplegroup)rversionmrrrr!s z)MySQLDialect_mysqldb._parse_dbapi_versionc Cs8ztdj}|j|_WdSttfk r2YdSXdS)NzMySQLdb.cursorsTF) __import__cursorsZSSCursorZ _sscursor ImportErrorAttributeError)rr2rrrsupports_server_side_cursorss  z1MySQLDialect_mysqldb.supports_server_side_cursorscCstdS)NZMySQLdb)r1)clsrrrr szMySQLDialect_mysqldb.dbapicstt|fdd}|S)NcsBdk r||}|dk r>|}|d||dS)Nz SET NAMES %s)character_set_namerexecuteclose)conn charset_namerZsuper_rr on_connectsz3MySQLDialect_mysqldb.on_connect..on_connect)rrr=)rr=r#r<rr=s zMySQLDialect_mysqldb.on_connectc CsXz|dWn@|jjk rN}z|||drs[        Q