
    [h                     B    d Z ddlmZ ddlmZ  G d de          ZeZdS )a  

.. dialect:: mysql+pymysql
    :name: PyMySQL
    :dbapi: pymysql
    :connectstring: mysql+pymysql://<username>:<password>@<host>/<dbname>[?<options>]
    :url: https://pymysql.readthedocs.io/

Unicode
-------

Please see :ref:`mysql_unicode` for current recommendations on unicode
handling.

.. _pymysql_ssl:

SSL Connections
------------------

The PyMySQL DBAPI accepts the same SSL arguments as that of MySQLdb,
described at :ref:`mysqldb_ssl`.   See that section for additional examples.

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`` in PyMySQL::

    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"
    )

MySQL-Python Compatibility
--------------------------

The pymysql DBAPI is a pure Python port of the MySQL-python (MySQLdb) driver,
and targets 100% compatibility.   Most behavioral notes for MySQL-python apply
to the pymysql driver as well.

   )MySQLDialect_mysqldb   )langhelpersc                        e Zd ZdZdZdZej        d             Ze	d             Z
ej        d             Zd Zd fd	Z fd	Zd
 Z xZS )MySQLDialect_pymysqlpymysqlTNc                 x    	 t          d          j        }|j        | _        dS # t          t
          f$ r Y dS w xY w)Nzpymysql.cursorsTF)
__import__cursorsSSCursor	_sscursorImportErrorAttributeError)selfr   s     p/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/pymysql.pysupports_server_side_cursorsz1MySQLDialect_pymysql.supports_server_side_cursors?   sN    	 !233;G$-DN4^, 	 	 	55	s    $ 99c                      t          d          S )Nr   )r
   )clss    r   import_dbapiz!MySQLDialect_pymysql.import_dbapiH   s    )$$$    c                    	 t          d          j        j        }t          j        |j                  }	 |j        d         }|dk    o|j         p|j        d         duS # t          $ r Y dS w xY w# t          t          f$ r Y dS w xY w)a  determine if pymysql has deprecated, changed the default of,
        or removed the 'reconnect' argument of connection.ping().

        See #10492 and
        https://github.com/PyMySQL/mysqlclient/discussions/651#discussioncomment-7308971
        for background.

        zpymysql.connectionsr   	reconnect    FT)r
   connections
Connectionr   get_callable_argspecpingargsdefaults
IndexErrorr   r   )r   r   inspreconnect_args       r   _send_false_to_pingz(MySQLDialect_pymysql._send_false_to_pingL   s    	#% *  3JODDD $	! %3 %Fq)9)F    uu ^, 	 	 	44	s"   A0 A 
A-,A-0BBc                 h    | j         r|                    d           n|                                 dS )NFT)r#   r   )r   dbapi_connections     r   do_pingzMySQLDialect_pymysql.do_pingh   s;    # 	$!!%((((!!###tr   c                 n    |t          d          }t                                          ||          S )Nuser)username)_translate_args)dictsupercreate_connect_args)r   urlr*   	__class__s      r   r-   z(MySQLDialect_pymysql.create_connect_argsp   s?    ""F333Oww** + 
 
 	
r   c                     t                                          |||          rdS t          || j        j                  r)t          |                                          }d|v pd|v S dS )NTzalready closedzconnection was killedF)r,   is_disconnect
isinstancedbapiErrorstrlower)r   e
connectioncursorstr_er/   s        r   r1   z"MySQLDialect_pymysql.is_disconnectw   so    77  J77 	44:+,, 	FFLLNNE E)M-D-M 5r   c                 v    t          |j        d         t                    r|j        d         }|j        d         S )Nr   )r2   r   	Exception)r   	exceptions     r   _extract_error_codez(MySQLDialect_pymysql._extract_error_code   s4    inQ'33 	*!q)I~a  r   )N)__name__
__module____qualname__driversupports_statement_cachedescription_encodingr   memoized_propertyr   classmethodr   r#   r&   r-   r1   r>   __classcell__)r/   s   @r   r   r   9   s        F#"  #" % % [% "  #"6  
 
 
 
 
 
	 	 	 	 	! ! ! ! ! ! !r   r   N)__doc__mysqldbr   utilr   r   dialect r   r   <module>rM      su   ) )V * ) ) ) ) )      L! L! L! L! L!/ L! L! L!^ r   