ó
    øÞ j  ã                  óú   • 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      Ú[/var/www/html/gaurav/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_pymysqléc   Ú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_cursorsÚ1MySQLDialect_pymysql.supports_server_side_cursorsi   s?   € ð	Ü Ð!2Ó3×;Ñ;ˆGØ$×-Ñ-ˆDŒNØøÜœ^Ð,ó 	Ùð	ú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Ÿ*™*ð ô 4°JÓ?Ð?øô œ^Ð,ó 	Ùð	ú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Ñ3ˆOÜ‰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Ü˜“F—L‘L“NˆEà  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   € Ü�i—n‘n QÑ'¬×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   