HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/clcommon/__pycache__/mysql_lib.cpython-311.pyc
�

�>1f�
���ddlmZddlZddlmZddlZddlmZddlm	Z	dZ
dZdZGd	�d
ej
��ZGd�d��Zd
�Ze
eefd�dd�ZdS)�)�annotationsN)�Iterable)�
DictCursor)�	load_fastz/etc/psa/psa.confz/etc/my.cnfz/etc/mysql/my.cnfc��eZdZdS)�
MySQLErrorN)�__name__�
__module__�__qualname__����/builddir/build/BUILDROOT/alt-python27-cllib-3.4.3-1.el8.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/mysql_lib.pyrrs�������Dr
rc�z�eZdZddd�Zd�Zd�Zdd�Zdd
�Zdd�Zd�Z	e
d
���Zddd�Ze
dd���ZdS) �MySQLConnectorF�as_dict�boolc��|�|�dd��|��d|_|rtnd|_||_dS)N�host�	localhost)�add_unix_socket_if_localhost�get�_connectionr�_cursor_type�_connect_kwargs)�selfr�kwargss   r�__init__zMySQLConnector.__init__sM���)�)�&�*�*�V�[�*I�*I�6�R�R�R����*1�;�J�J�t���%����r
c�*�|���S�N)�connect�rs r�	__enter__zMySQLConnector.__enter__$s���|�|�~�~�r
c�.�|���dSr)�close)r�exc_type�	exc_value�	tracebacks    r�__exit__zMySQLConnector.__exit__'s���
�
�����r
�returnc�<�tjdi|j��|_|S)Nr)�pymysqlr rrr!s rr zMySQLConnector.connect*s"��"�?�B�B�T�-A�B�B����r
�Nonec�J�|j�|j���dSdSr)rr$r!s rr$zMySQLConnector.close.s.����'���"�"�$�$�$�$�$�(�'r
c�J�|j�|j���dSdSr)r�commitr!s rr/zMySQLConnector.commit2s.����'���#�#�%�%�%�%�%�(�'r
c�@�|j�|j��Sr)�
connection�cursorrr!s rr2zMySQLConnector.cursor6s����%�%�d�&7�8�8�8r
c�F�|j�|���|jSr)rr r!s rr1zMySQLConnector.connection9s!����#��L�L�N�N�N���r
N�	sql_query�str�args�Iterable[object] | None�&tuple[object, ...] | dict[str, object]c���|j�|j��5}|�||���|���cddd��S#1swxYwYdS)z:
        Execute SQL query and return the result.
        )r6N)r1r2r�execute�fetchall)rr4r6r2s    r�
execute_queryzMySQLConnector.execute_query?s����_�
#�
#�D�$5�
6�
6�	%�&��N�N�9�4�N�0�0�0��?�?�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	%�	%s�+A�A�Arr�dictc�D�|dkrd|vrt��|d<dSdSdS)ag
        Add 'unix_socket' to kwargs if host is 'localhost'.

        It seems that when the host is set to 'localhost',
        establishing a connection through TCP/IP might encounter issues
        due to some MySQL configuration options.
        To prioritize a Unix socket connection,
        we should include the 'unix_socket' query parameter.
        r�unix_socketN)�get_unix_socket_path)rrs  rrz+MySQLConnector.add_unix_socket_if_localhostGs=���;���=��#>�#>�$8�$:�$:�F�=�!�!�!���#>�#>r
)F)rr)r)r)r)r,r)r4r5r6r7r)r8)rr5rr=r)r,)r	r
rrr"r(r r$r/r2�propertyr1r<�staticmethodrrr
rrrs�������&�&�&�&�&�����������%�%�%�%�&�&�&�&�9�9�9�� � ��X� �
%�%�%�%�%��;�;�;��\�;�;�;r
rc�P�t�|j|j��|S)zF
    Get a modified RFC 1738 URL for a MySQL database connection.
    )rrr�query)�urls r�get_rfc1738_db_urirFVs#���/�/���#�)�D�D�D��Jr
)�plesk_config_path�
mysql_configsrGr5rH�
Iterable[str]r)c�:�tj�|��r*t|d���}|�d��}|�|S|D]N}tj�|��s�"t|d���}|�d��}|�|cS�OdS)	z�
    Get the Unix socket path for MySQL connection.

    Check Plesk and MySQL config files for the socket path.
    If found, return that path. If not, return default socket path.
    � )�	delimiter�MYSQL_SOCKETNT)�strip_quotes�socketz/var/lib/mysql/mysql.sock)�os�path�isfilerr)rGrH�psa_conf�psa_conf_socket�my_conf_path�my_conf�my_conf_sockets       rr@r@^s���
�w�~�~�'�(�(�#��.�#�>�>�>��"�,�,�~�6�6���&�"�"�%�"�"���w�~�~�l�+�+�	���L�t�<�<�<�� ���X�.�.���%�!�!�!�!�&�'�&r
)rGr5rHrIr)r5)�
__future__rrP�typingrr+�pymysql.cursorsr�clcommon.clconfparsr�PLESK_CONFIG_PATH�MY_CONFIG_PATH�MY_CONFIG_PATH2�ErrorrrrFr@rr
r�<module>r`s
��#�"�"�"�"�"�	�	�	�	�����������&�&�&�&�&�&�)�)�)�)�)�)�'����%��	�	�	�	�	���	�	�	�8;�8;�8;�8;�8;�8;�8;�8;�v���/�$2�O�#D�'�'�'�'�'�'�'�'r