§
    eŠtj  ã                  óö   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 d	d
l
mZ ddlmZ ddlmZ er$ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd„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.

é    )Úannotations)ÚAny)ÚDict)ÚOptional)ÚType)ÚTYPE_CHECKING)ÚUnioné   )ÚMySQLDialect_mysqldbé   )Úlanghelpers)ÚLiteral)ÚConnectArgsType)ÚDBAPIConnection)ÚDBAPICursor)ÚDBAPIModule)ÚPoolProxiedConnection)ÚURLÚconnection_clsú	Type[Any]ÚreturnÚboolc                ó¬   — t          j        | j        ¦  «        }	 |j        d         }|dk    o|j         p|j        d         duS # t
          $ r Y dS w xY w)ax  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)r   ÚinspÚreconnect_args      ú_/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/pymysql.pyÚ _connection_ping_reconnects_truer#   J   sx   € õ Ô+¨NÔ,?Ñ@Ô@€Dð
Øœ	 !œˆð  Ò+ð 
Ø”ÐÐ> ¤¨qÔ!1¸Ð!>ð	
øõ ð ð ð Øˆuˆuðøøøs   ›A Á
AÁAc                  ó¨   ‡ — e Zd ZdZdZdZej        dd„¦   «         Ze	d d„¦   «         Z
ej        dd	„¦   «         Zd!d„Z	 d"d#ˆ fd„Zd$ˆ fd„Zd%d„Zˆ xZS )&ÚMySQLDialect_pymysqlÚpymysqlTNr   r   c                ó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     r"   Úsupports_server_side_cursorsz1MySQLDialect_pymysql.supports_server_side_cursorsi   sN   € ð	Ý Ð!2Ñ3Ô3Ô;ˆGØ$Ô-ˆDŒNØ�4øÝ�^Ð,ð 	ð 	ð 	Ø�5�5ð	øøøs   ‚ $ ¤9¸9r   c                ó    — t          d¦  «        S )Nr&   )r(   )Úclss    r"   Úimport_dbapiz!MySQLDialect_pymysql.import_dbapir   s   € å˜)Ñ$Ô$Ð$ó    c                ó„   — 	 t          d¦  «        j        j        }t          |¦  «        S # t          t
          f$ r Y dS w xY w)a4  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_pingz(MySQLDialect_pymysql._send_false_to_pingv   s[   € ð	@Ý#Ø%ñô äœ*ð õ 4°JÑ?Ô?Ð?øõ �^Ð,ð 	ð 	ð 	Ø�4�4ð	øøøs   ‚* ª?¾?Údbapi_connectionr   úLiteral[True]c                óh   — | j         r|                     d¦  «         n|                     ¦   «          dS )NFT)r7   r   )r.   r8   s     r"   Údo_pingzMySQLDialect_pymysql.do_pingŒ   s;   € ØÔ#ð 	$Ø×!Ò! %Ñ(Ô(Ð(Ð(à×!Ò!Ñ#Ô#Ð#àˆtr3   Úurlr   Ú_translate_argsúOptional[Dict[str, Any]]r   c                ón   •— |€t          d¬¦  «        }t          ¦   «                              ||¬¦  «        S )NÚuser)Úusername)r=   )ÚdictÚsuperÚcreate_connect_args)r.   r<   r=   Ú	__class__s      €r"   rD   z(MySQLDialect_pymysql.create_connect_args”   sA   ø€ ð Ð"Ý"¨FÐ3Ñ3Ô3ˆOÝ‰wŒw×*Ò*Ø ð +ñ 
ô 
ð 	
r3   ÚeúDBAPIModule.ErrorÚ
connectionú7Optional[Union[PoolProxiedConnection, DBAPIConnection]]ÚcursorúOptional[DBAPICursor]c                óØ   •— t          ¦   «                              |||¦  «        rdS t          || j        j        ¦  «        r)t          |¦  «                             ¦   «         }d|v pd|v S dS )NTzalready closedzconnection was killedF)rC   Úis_disconnectÚ
isinstanceÚloaded_dbapiÚErrorÚstrÚlower)r.   rF   rH   rJ   Ústr_erE   s        €r"   rM   z"MySQLDialect_pymysql.is_disconnect�   sr   ø€ õ ‰7Œ7× Ò   J°Ñ7Ô7ð 	Ø�4Ý˜˜4Ô,Ô2Ñ3Ô3ð 	Ý˜‘F”F—L’L‘N”NˆEà  EÐ)ÐMÐ-DÈÐ-Mðð �5r3   Ú	exceptionÚBaseExceptionr   c                óv   — t          |j        d         t          ¦  «        r|j        d         }|j        d         S )Nr   )rN   r   Ú	Exception)r.   rT   s     r"   Ú_extract_error_codez(MySQLDialect_pymysql._extract_error_code­   s4   € Ý�i”n QÔ'­Ñ3Ô3ð 	*Ø!œ qÔ)ˆIØŒ~˜aÔ Ð r3   )r   r   )r   r   )r8   r   r   r9   )N)r<   r   r=   r>   r   r   )rF   rG   rH   rI   rJ   rK   r   r   )rT   rU   r   r   )Ú__name__Ú
__module__Ú__qualname__ÚdriverÚsupports_statement_cacheÚdescription_encodingr   Úmemoized_propertyr/   Úclassmethodr2   r7   r;   rD   rM   rX   Ú__classcell__)rE   s   @r"   r%   r%   c   s
  ø€ € € € € Ø€FØ#ÐàÐàÔ"ðð ð ñ #Ô"ðð ð%ð %ð %ñ „[ð%ð Ô"ð@ð @ð @ñ #Ô"ð@ð*ð ð ð ð EIð
ð 
ð 
ð 
ð 
ð 
ð 
ðð ð ð ð ð ð !ð !ð !ð !ð !ð !ð !ð !r3   r%   N)r   r   r   r   )Ú__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>rl      s�  ðð)ð )ðV #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð à )Ð )Ð )Ð )Ð )Ð )Ø Ð Ð Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "àð "à4Ð4Ð4Ð4Ð4Ð4Ø4Ð4Ð4Ð4Ð4Ð4Ø0Ð0Ð0Ð0Ð0Ð0Ø0Ð0Ð0Ð0Ð0Ð0Ø:Ð:Ð:Ð:Ð:Ð:Ø!Ð!Ð!Ð!Ð!Ð!ð
ð 
ð 
ð 
ð2M!ð M!ð M!ð M!ð M!Ð/ñ M!ô M!ð M!ð` €€€r3   