
    Oj                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  S	S
K
Jr  SSKJr  SSKJr  \(       a$  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SS jr " S S\5      r\rg)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.

    )annotations)Any)Dict)Optional)Type)TYPE_CHECKING)Union   )MySQLDialect_mysqldb   )langhelpers)Literal)ConnectArgsType)DBAPIConnection)DBAPICursor)DBAPIModule)PoolProxiedConnection)URLc                    [         R                  " U R                  5      n UR                  S   nUS:H  =(       a)    UR                  (       + =(       d    UR                  S   SL$ ! [
         a     gf = f)aT  Given a Connection class like pymysql.Connection, aiomysql.Connection,
asyncmy.Connection, inspect the ping() method and determine if it
has a "reconnect" parameter that either defaults to True, or is positional.

a return value of True here means that when we call ``connection.ping()``,
we **must** pass `reconnect=False`.  a return value of False means that
we should call ``connection.ping()`` with **no arguments**.

This routine originates from issue #10492 for pymysql, however arg
signature mismatches in aiomysql/asyncmy tracked by issue #13306
necessitated a more open ended function.

r
   	reconnectr   F)r   get_callable_argspecpingargsdefaults
IndexError)connection_clsinspreconnect_args      c/var/www/html/leaf-doctor-v1/venv/lib/python3.13/site-packages/sqlalchemy/dialects/mysql/pymysql.py _connection_ping_reconnects_truer    J   sq     ++N,?,?@D
		! + 
>q!1!>	
  s   A& &
A32A3c                     ^  \ rS rSrSrSrSr\R                  SS j5       r	\
SS j5       r\R                  SS j5       rSS jr S     SU 4S	 jjjr        SU 4S
 jjrSS jrSrU =r$ )MySQLDialect_pymysqlc   pymysqlTNc                ~     [        S5      R                  nUR                  U l        g! [        [
        4 a     gf = f)Nzpymysql.cursorsTF)
__import__cursorsSSCursor	_sscursorImportErrorAttributeError)selfr'   s     r   supports_server_side_cursors1MySQLDialect_pymysql.supports_server_side_cursorsi   s?    	 !23;;G$--DN^, 		s   &) <<c                    [        S5      $ )Nr$   )r&   )clss    r   import_dbapi!MySQLDialect_pymysql.import_dbapir   s    )$$    c                     [        S5      R                  R                  n[        U5      $ ! [        [
        4 a     gf = f)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.

Revised as part of #13306

zpymysql.connectionsT)r&   connections
Connectionr    r*   r+   )r,   r6   s     r   _send_false_to_ping(MySQLDialect_pymysql._send_false_to_pingv   sG    	@#%k**  4J?? ^, 		s   , ??c                j    U R                   (       a  UR                  S5        gUR                  5         g)NFT)r7   r   )r,   dbapi_connections     r   do_pingMySQLDialect_pymysql.do_ping   s/    ##!!%(  !!#r3   c                6   > Uc	  [        SS9n[        TU ]	  XS9$ )Nuser)username)_translate_args)dictsupercreate_connect_args)r,   urlr@   	__class__s      r   rC   (MySQLDialect_pymysql.create_connect_args   s/     ""F3Ow* + 
 	
r3   c                   > [         TU ]  XU5      (       a  g[        XR                  R                  5      (       a*  [        U5      R                  5       nSU;   =(       d    SU;   $ g)NTzalready closedzconnection was killedF)rB   is_disconnect
isinstanceloaded_dbapiErrorstrlower)r,   e
connectioncursorstr_erE   s        r   rH   "MySQLDialect_pymysql.is_disconnect   s]     7 77,,2233FLLNE E)M-D-M r3   c                    [        UR                  S   [        5      (       a  UR                  S   nUR                  S   $ )Nr   )rI   r   	Exception)r,   	exceptions     r   _extract_error_code(MySQLDialect_pymysql._extract_error_code   s5    innQ'33!q)I~~a  r3   )r)   )returnbool)rX   r   )r:   r   rX   zLiteral[True])N)rD   r   r@   zOptional[Dict[str, Any]]rX   r   )rN   zDBAPIModule.ErrorrO   z7Optional[Union[PoolProxiedConnection, DBAPIConnection]]rP   zOptional[DBAPICursor]rX   rY   )rU   BaseExceptionrX   r   )__name__
__module____qualname____firstlineno__driversupports_statement_cachedescription_encodingr   memoized_propertyr-   classmethodr1   r7   r;   rC   rH   rV   __static_attributes____classcell__)rE   s   @r   r"   r"   c   s    F#"" # % % ""@ #@* EI

)A
	
 
 L &	
 
 ! !r3   r"   N)r   z	Type[Any]rX   rY   )__doc__
__future__r   typingr   r   r   r   r   r	   mysqldbr   utilr   util.typingr   engine.interfacesr   r   r   r   r   
engine.urlr   r    r"   dialect r3   r   <module>rp      s\   )V #        )  "4400:!
2M!/ M!` r3   