HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/mysql/connector/aio/__pycache__/__init__.cpython-39.pyc
a

�,�h($�@s�dZgd�ZddlZddlmZddlmZddlmZm	Z	m
Z
ddlmZd	d
l
mZd	dlmZzddlZddlZWney�dZYn0d
Zzd	dlmZWney�dZYn0eeed�dd�Zeed�dd�ZdS)z8MySQL Connector/Python - MySQL driver written in Python.)�CMySQLConnection�MySQLConnection�connect�N)�Any�)�DEFAULT_CONFIGURATION)�Error�InterfaceError�ProgrammingError)�
ERROR_NO_CEXT�)�MySQLConnectionAbstract)rFT)r)�args�kwargs�returnc�s�d|vr|�d�nd}t|t�s(td��|�rts:td��d|vrJtd��d|vrZtd��d	|vrjtd
��d|vr~td|d<ztj�|dd�}Wn,tj	j
y�td
|d�d��d�Yn0g}|D](}|�|jj
dd�|j|j|jd��q�|jdd�d�dd�|D�|d	<d	|v�r4tfi|��IdHS|�dd�}d|v�rh|d=|�shtdu�rhtt��t�r�|�s�t|i|��}nt|i|��}|��IdH|S)a�Creates or gets a MySQL connection object.

    In its simpliest form, `connect()` will open a connection to a
    MySQL server and return a `MySQLConnectionAbstract` subclass
    object such as `MySQLConnection` or `CMySQLConnection`.

    When any connection pooling arguments are given, for example `pool_name`
    or `pool_size`, a pool is created or a previously one is used to return
    a `PooledMySQLConnection`.

    Args:
        *args: N/A.
        **kwargs: For a complete list of possible arguments, see [1]. If no arguments
                  are given, it uses the already configured or default values.

    Returns:
        A `MySQLConnectionAbstract` subclass instance (such as `MySQLConnection` or
        a `CMySQLConnection`) instance.

    Examples:
        A connection with the MySQL server can be established using either the
        `mysql.connector.connect()` method or a `MySQLConnectionAbstract` subclass:
        ```
        >>> from mysql.connector.aio import MySQLConnection, HAVE_CEXT
        >>>
        >>> cnx1 = await mysql.connector.aio.connect(user='joe', database='test')
        >>> cnx2 = MySQLConnection(user='joe', database='test')
        >>> await cnx2.connect()
        >>>
        >>> cnx3 = None
        >>> if HAVE_CEXT:
        >>>     from mysql.connector.aio import CMySQLConnection
        >>>     cnx3 = CMySQLConnection(user='joe', database='test')
        ```

    References:
        [1]: https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html
    �dns_srvFz(The value of 'dns-srv' must be a booleanztMySQL host configuration requested DNS SRV. This requires the Python dnspython module. Please refer to documentation�unix_socketz<Using Unix domain sockets with DNS SRV lookup is not allowed�portz;Specifying a port number with DNS SRV lookup is not allowed�failoverzASpecifying multiple hostnames with DNS SRV look up is not allowed�hostZSRVz Unable to locate any hosts for '�'NT)Zomit_final_dot)rr�priority�weightcSs|d|dfS)Nrr���xrr�O/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/connector/aio/__init__.py�<lambda>��zconnect.<locals>.<lambda>)�keycSsg|]}|d|dd��qS)rr)rrr)�.0�srvrrr�
<listcomp>�szconnect.<locals>.<listcomp>�use_pure)�pop�
isinstance�boolr	�HAVE_DNSPYTHONr�dns�resolver�query�	exceptionZDNSException�append�targetZto_textrrr�sort�_get_failover_connection�getr�ImportErrorrrr)rrrZsrv_recordsrr!r#Zcnxrrrr:sn(
��������	�


r)rrc
�s4|��}z|d}Wnty0td�d�Yn0|d=tgd��}d}|D]�}t|���|}|r�t|�dkrtdnd}d	�|�}td
|�d|����t|d�r�|d7}|�dd
�|d<|ddks�|dd
kr�t	d|d����t
|dt�sLt	d|d����qLd|k�r t|�k�r,nntd��i}	g}
t
|dd�dd�D]D}|d|	v�rv|g|	|d<|
�|d�n|	|d�|��qF|
D]�}|	|}tt|��D]z}
t|�d}t�d|�}|�|�}|��}|�|�|�dd�ztfi|��IdHWSt�yYn0�q��q�t	d��dS)a�Return a MySQL connection and try to failover if needed.

    An InterfaceError is raise when no MySQL is available. ValueError is
    raised when the failover server configuration contains an illegal
    connection argument. Supported arguments are user, password, host, port,
    unix_socket and database. ValueError is also raised when the failover
    argument was not provided.

    Returns MySQLConnection instance.
    rzfailover argument not providedN)	�user�passwordrrrZdatabaseZ	pool_nameZ	pool_sizerrr�s�z, z Unsupported connection argument z in failover: r�dz9Priority value should be in the range of 0 to 100, got : zDPriority value should be an integer in the range of 0 to 100, got : z\You must either assign no priority to any of the routers or give a priority for every routercSs|dS)Nrrrrrrr�rz*_get_failover_connection.<locals>.<lambda>T)r�reversez,Unable to connect to any of the target hosts)�copy�KeyError�
ValueError�set�keys�len�join�hasattrr0r	r%�intr
�sortedr,�range�random�randintr$�updaterr)r�configrZsupport_cnx_argsZpriority_count�server�diff�arg�lstZserver_directoryZserver_priority_listrZ
failover_list�_�last�indexZ
new_configrrrr/�st�
�
���� �

r/)�__doc__�__all__rC�typingr�	constantsr�errorsrr	r
ZpoolingrZ	abstractsr
�
connectionrZ
dns.exceptionr(Zdns.resolverr1r'Zconnection_cextrrr/rrrr�<module>s(

m