
    ؄_                         d Z ddl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
  G d de          Z G d de          Z G d de          Z G d de          Z G d de          ZeZdS )a  
.. dialect:: mysql+mysqlconnector
    :name: MySQL Connector/Python
    :dbapi: myconnpy
    :connectstring: mysql+mysqlconnector://<user>:<password>@<host>[:<port>]/<dbname>
    :url: https://pypi.org/project/mysql-connector-python/

.. note::

    The MySQL Connector/Python DBAPI has had many issues since its release,
    some of which may remain unresolved, and the mysqlconnector dialect is
    **not tested as part of SQLAlchemy's continuous integration**.
    The recommended MySQL dialects are mysqlclient and PyMySQL.

    N   )BIT)MySQLCompiler)MySQLDialect)MySQLExecutionContext)MySQLIdentifierPreparer   )
processors)utilc                       e Zd Zd ZdS )$MySQLExecutionContext_mysqlconnectorc                     | j         j        S N)cursor	lastrowidselfs    m/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqlconnector.pyget_lastrowidz2MySQLExecutionContext_mysqlconnector.get_lastrowid$   s    {$$    N)__name__
__module____qualname__r    r   r   r   r   #   s#        % % % % %r   r   c                        e Zd Zd Zd Zd ZdS )MySQLCompiler_mysqlconnectorc                     | j         j        r* | j        |j        fi |dz    | j        |j        fi |z   S  | j        |j        fi |dz    | j        |j        fi |z   S )Nz %% z % )dialect_mysqlconnector_double_percentsprocessleftright)r   binaryoperatorkws       r   visit_mod_binaryz-MySQLCompiler_mysqlconnector.visit_mod_binary)   s    <7 	V[//B//$,v|22r223 V[//B//$,v|22r223r   c                 J    | j         j        r|                    dd          S |S N%z%%r   r   replacer   texts     r   post_process_textz.MySQLCompiler_mysqlconnector.post_process_text7   (    <7 	<<T***Kr   c                 J    | j         j        r|                    dd          S |S r(   r*   r,   s     r   escape_literal_columnz2MySQLCompiler_mysqlconnector.escape_literal_column=   r/   r   N)r   r   r   r&   r.   r1   r   r   r   r   r   (   sA                r   r   c                   J    e Zd Zed             Zej        d             Zd ZdS )&MySQLIdentifierPreparer_mysqlconnectorc                     | j         j        S r   )r   r   r   s    r   _double_percentsz7MySQLIdentifierPreparer_mysqlconnector._double_percentsE   s    |;;r   c                     d S r   r   r   values     r   r5   z7MySQLIdentifierPreparer_mysqlconnector._double_percentsI   s    r   c                     |                     | j        | j                  }| j        j        r|                     dd          S |S r(   )r+   escape_quoteescape_to_quoter   r   r7   s     r   _escape_identifierz9MySQLIdentifierPreparer_mysqlconnector._escape_identifierM   sA    d/1EFF<7 	==d+++Lr   N)r   r   r   propertyr5   setterr<   r   r   r   r3   r3   D   s[        < < X<       r   r3   c                       e Zd Zd ZdS )_myconnpyBITc                     dS )z0MySQL-connector already converts mysql bits, so.Nr   )r   r   coltypes      r   result_processorz_myconnpyBIT.result_processorV   s	     tr   N)r   r   r   rC   r   r   r   r@   r@   U   s#            r   r@   c                   V    e Zd ZdZdZdZdZdZdZe	Z
eZeZ ej        ej        eei          Z fdZd Zed             Zej        d             Zed             Zd	 Zd
 Zej        d             Zej        d             Z d Z!d Z"d Z#ddZ$ddZ% e&g d          Z' fdZ( xZ)S )MySQLDialect_mysqlconnectormysqlconnectorTformatc                      t          t          |           j        |i | t          j        | j                  | _        d S r   )superrE   __init__r
   (to_conditional_unicode_processor_factorydescription_encoding_description_decoder)r   argr%   	__class__s      r   rJ   z$MySQLDialect_mysqlconnector.__init__n   sI    9)40093E"EEE
 ?

#%% %%!!!r   c                     dS )NFr   r   
connections     r   _check_unicode_descriptionz6MySQLDialect_mysqlconnector._check_unicode_descriptionw   s	     ur   c                     dS )Nzlatin-1r   r   s    r   rL   z0MySQLDialect_mysqlconnector.description_encoding|   s	     yr   c                 0    t           j        p
| j        dk    S N)   r   r   py3k_mysqlconnector_version_infor   s    r   supports_unicode_statementsz7MySQLDialect_mysqlconnector.supports_unicode_statements   s    yFD=FFr   c                     ddl m} |S )Nr   )	connector)mysqlr]   )clsr]   s     r   dbapiz!MySQLDialect_mysqlconnector.dbapi   s    ######r   c                     	 |                     d           dS # | j        j        $ r#}|                     ||d           rY d }~dS  d }~ww xY w)NFT)pingr`   Erroris_disconnect)r   dbapi_connectionerrs      r   do_pingz#MySQLDialect_mysqlconnector.do_ping   ss    	!!%((( 4 z 	 	 	!!#'7>> uuuuu		s    AAAAc                    |                     d          }|                    |j                   t          j        |dt
                     t          j        |dt
                     t          j        |dt
                     t          j        |dt
                     t          j        |dt                     t          j        |dt                     t          j        |d	t
                     t          j        |d
t
                     t          j        |dt
                     t          j        |dt
                     t          j        |dt                     t          j        |dt
                     t          j        |dt
                     t          j        |dt
                     t          j        |dt
                     t          j        |dt
                     |                    dd           | j        O	 ddl	m
} |                    d|                                          }||j        z  }||d<   n# t          $ r Y nw xY wg |gS )Nuser)usernameallow_local_infile
autocommitbufferedcompressconnection_timeoutconnect_timeoutconsume_results
force_ipv6get_warningspool_reset_session	pool_sizeraise_on_warningsrawssl_verify_certuse_pureuse_unicodeTr   )
ClientFlagclient_flags)translate_connect_argsupdatequeryr   coerce_kw_typeboolint
setdefaultr`   mysql.connector.constantsr{   getget_default
FOUND_ROWS	Exception)r   urloptsr{   r|   s        r   create_connect_argsz/MySQLDialect_mysqlconnector.create_connect_args   s$   ))6)::CID"6===D,555D*d333D*d333D"6<<<D"3S999D"3T:::D,555D.$777D"6===D+s333D"5t<<<D%...D"3T:::D*d333D-666 	
D))) :!	@@@@@@#xx"J$:$:$<$<    
 55'3^$$   Dzs   ?=H= =
I
	I
c                     | j         rdt          | j         d          rQt          j        d| j         j                  }|r2t          d |                    ddd          D                       S d S d S d S )N__version__z(\d+)\.(\d+)(?:\.(\d+))?c              3   8   K   | ]}|t          |          V  d S r   )r   ).0xs     r   	<genexpr>zKMySQLDialect_mysqlconnector._mysqlconnector_version_info.<locals>.<genexpr>   s(      OOSVVOOr   r   rW   r	   )r`   hasattrrematchr   tuplegroup)r   ms     r   rZ   z8MySQLDialect_mysqlconnector._mysqlconnector_version_info   s    : 	P'$*m<< 	P4dj6LMMA POOQWWQ1-=-=OOOOOO	P 	P 	P 	PP Pr   c                 2    t           j         o
| j        dk     S rV   rX   r   s    r   r   z;MySQLDialect_mysqlconnector._mysqlconnector_double_percents   s    9}K!BV!KKr   c                     |j         j        S r   )rR   charsetrQ   s     r   _detect_charsetz+MySQLDialect_mysqlconnector._detect_charset   s    $,,r   c                     |j         S r   )errno)r   	exceptions     r   _extract_error_codez/MySQLDialect_mysqlconnector._extract_error_code   s
    r   c                     d}| j         j        | j         j        f}t          ||          r+|j        |v p!dt          |          v pdt          |          v S dS )N)i  i  i  i  i  i   zMySQL Connection not available.z$Connection to MySQL is not availableF)r`   OperationalErrorInterfaceError
isinstancer   str)r   erR   r   errnos
exceptionss         r   rd   z)MySQLDialect_mysqlconnector.is_disconnect   sk    5j14:3LM
a$$ 	6! D4A>D9SVVC 5r   Nc                 *    |                                 S r   )fetchallr   rpr   s      r   _compat_fetchallz,MySQLDialect_mysqlconnector._compat_fetchall       {{}}r   c                 *    |                                 S r   )fetchoner   s      r   _compat_fetchonez,MySQLDialect_mysqlconnector._compat_fetchone   r   r   )SERIALIZABLEzREAD UNCOMMITTEDzREAD COMMITTEDzREPEATABLE READ
AUTOCOMMITc                     |dk    r	d|_         d S d|_         t          t          |                               ||           d S )Nr   TF)rl   rI   rE   _set_isolation_level)r   rR   levelrO   s      r   r   z0MySQLDialect_mysqlconnector._set_isolation_level   sV    L  $(J!!!$)J!-t44IIE    r   r   )*r   r   r   driversupports_unicode_bindssupports_sane_rowcountsupports_sane_multi_rowcountsupports_native_decimaldefault_paramstyler   execution_ctx_clsr   statement_compilerr3   preparerr   update_copyr   colspecsr   r@   rJ   rS   r=   rL   memoized_propertyr[   classmethodr`   rg   r   rZ   r   r   r   rd   r   r   set_isolation_lookupr   __classcell__)rO   s   @r   rE   rE   \   s       F!!#' "!<55Ht 5\7JKKH% % % % %  
   X 
G G G   [
	 	 	' ' 'R 
P P P 
L L L- - -  
 
 
       	
 	
 	
         r   rE   )__doc__r   baser   r   r   r   r    r
   r   r   r   r3   r@   rE   r   r   r   r   <module>r      s     
			                   ' ' ' ' ' ' ) ) ) ) ) )            % % % % %+@ % % %
    =   8    -D   "    3   W W W W W, W W Wt &r   