a
    [ga                     @   s   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 G d
d deZ	G dd deZ
G dd deZG d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)MySQLIdentifierPreparer   )utilc                   @   s   e Zd Zdd ZdS )MySQLCompiler_mysqlconnectorc                 K   s,   | j |jfi |d | j |jfi | S )Nz % )processleftright)selfbinaryoperatorkw r   v/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/mysqlconnector.pyvisit_mod_binary$   s    z-MySQLCompiler_mysqlconnector.visit_mod_binaryN)__name__
__module____qualname__r   r   r   r   r   r	   #   s   r	   c                   @   s.   e Zd Zedd Zejdd Zdd ZdS )&MySQLIdentifierPreparer_mysqlconnectorc                 C   s   dS )NFr   )r   r   r   r   _double_percents-   s    z7MySQLIdentifierPreparer_mysqlconnector._double_percentsc                 C   s   d S Nr   r   valuer   r   r   r   1   s    c                 C   s   | | j| j}|S r   )replaceZescape_quoteZescape_to_quoter   r   r   r   _escape_identifier5   s    z9MySQLIdentifierPreparer_mysqlconnector._escape_identifierN)r   r   r   propertyr   setterr   r   r   r   r   r   ,   s
   

r   c                   @   s   e Zd Zdd ZdS )_myconnpyBITc                 C   s   dS )z0MySQL-connector already converts mysql bits, so.Nr   )r   dialectZcoltyper   r   r   result_processor;   s    z_myconnpyBIT.result_processorN)r   r   r   r"   r   r   r   r   r    :   s   r    c                       s   e Zd ZdZdZdZdZdZdZe	Z
eZeejeeiZedd Zdd Zdd	 Zejd
d Zdd Zdd Zdd ZdddZdddZh dZ fddZ  Z S )MySQLDialect_mysqlconnectorZmysqlconnectorTformatc                 C   s   ddl m} |S )Nr   )	connector)mysqlr%   )clsr%   r   r   r   import_dbapiQ   s    z(MySQLDialect_mysqlconnector.import_dbapic                 C   s   | d dS )NFT)Zping)r   Zdbapi_connectionr   r   r   do_pingW   s    
z#MySQLDialect_mysqlconnector.do_pingc                 C   sn  |j dd}||j t|dt t|dt t|dt t|dt t|dt t|dt t|d	t t|d
t t|dt t|dt t|dt t|dt t|dt t|dt t|dt t|dt t|dt |dd | jd urfz2ddl	m
} |d| }||jO }||d< W n tyd   Y n0 g |gS )Nuser)usernameZallow_local_infile
autocommitbufferedZclient_flagcompressZconnection_timeoutconnect_timeoutZconsume_resultsZ
force_ipv6Zget_warningsZpool_reset_sessionZ	pool_sizeZraise_on_warningsrawZssl_verify_certZuse_pureZuse_unicodeTr   )
ClientFlagclient_flags)Ztranslate_connect_argsupdatequeryr   Zcoerce_kw_typeboolint
setdefaultdbapiZmysql.connector.constantsr1   getget_defaultZ
FOUND_ROWS	Exception)r   urloptsr1   r2   r   r   r   create_connect_args[   s>    
z/MySQLDialect_mysqlconnector.create_connect_argsc                 C   sF   | j rBt| j drBtd| j j}|rBtdd |dddD S d S )N__version__z(\d+)\.(\d+)(?:\.(\d+))?c                 s   s   | ]}|d urt |V  qd S r   )r6   ).0xr   r   r   	<genexpr>       zKMySQLDialect_mysqlconnector._mysqlconnector_version_info.<locals>.<genexpr>r      r   )r8   hasattrrematchr?   tuplegroup)r   mr   r   r   _mysqlconnector_version_info   s    z8MySQLDialect_mysqlconnector._mysqlconnector_version_infoc                 C   s   |j jS r   )
connectioncharset)r   rL   r   r   r   _detect_charset   s    z+MySQLDialect_mysqlconnector._detect_charsetc                 C   s   |j S r   )errno)r   	exceptionr   r   r   _extract_error_code   s    z/MySQLDialect_mysqlconnector._extract_error_codec                 C   sH   d}| j j| j jf}t||r@|j|v p>dt|v p>dt|v S dS d S )N)i  i  i  i  i  i   zMySQL Connection not available.z$Connection to MySQL is not availableF)r8   ZOperationalErrorZInterfaceError
isinstancerO   str)r   erL   cursorZerrnos
exceptionsr   r   r   is_disconnect   s    



z)MySQLDialect_mysqlconnector.is_disconnectNc                 C   s   |  S r   )Zfetchallr   rprM   r   r   r   _compat_fetchall   s    z,MySQLDialect_mysqlconnector._compat_fetchallc                 C   s   |  S r   )ZfetchonerX   r   r   r   _compat_fetchone   s    z,MySQLDialect_mysqlconnector._compat_fetchone>   zREAD COMMITTEDzREAD UNCOMMITTED
AUTOCOMMITzREPEATABLE READZSERIALIZABLEc                    s(   |dkrd|_ nd|_ t || d S )Nr\   TF)r,   super_set_isolation_level)r   rL   level	__class__r   r   r^      s    z0MySQLDialect_mysqlconnector._set_isolation_level)N)N)!r   r   r   ZdriverZsupports_statement_cacheZsupports_sane_rowcountZsupports_sane_multi_rowcountZsupports_native_decimalZdefault_paramstyler	   Zstatement_compilerr   preparerr   Zupdate_copyr   Zcolspecsr   r    classmethodr(   r)   r>   Zmemoized_propertyrK   rN   rQ   rW   rZ   r[   Z_isolation_lookupr^   __classcell__r   r   r`   r   r#   A   s,   
*


r#   )__doc__rF   baser   r   r   r    r   r	   r   r    r#   r!   r   r   r   r   <module>
   s   	s