????

Your IP : 3.14.141.163


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/__pycache__/mysql_lib.cpython-311.pyc

�

�j�e�����ddlmZddlZddlmZ	ddlZddlmZn$#e$r	ddl	Zddl
mZn
#e$rdZYnwxYwYnwxYwddlmZddl
mZdZdZd	ZGd
�d��Zd�Zeeefd
�dd�ZdS)�)�annotationsN)�Iterable)�
DictCursor)�	load_fast)�	NoPackagez/etc/psa/psa.confz/etc/my.cnfz/etc/mysql/my.cnfc�z�eZdZddd�Zd�Zd�Zdd�Zdd
�Zdd�Zd�Z	e
d
���Zddd�Ze
dd���ZdS) �MySQLConnectorF�as_dict�boolc���t�td���|�|�dd��|��d|_|rt
nd|_||_dS)NzFCan not connect to database; MySQL-client libraries are not installed.�host�	localhost)�pymysqlr�add_unix_socket_if_localhost�get�_connectionr�_cursor_type�_connect_kwargs)�selfr
�kwargss   ��/builddir/build/BUILDROOT/alt-python27-cllib-3.3.15-1.el8.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/mysql_lib.py�__init__zMySQLConnector.__init__%si���?��X���
�	
�)�)�&�*�*�V�[�*I�*I�6�R�R�R����*1�;�J�J�t���%�����c�*�|���S�N)�connect�rs r�	__enter__zMySQLConnector.__enter__1s���|�|�~�~�rc�.�|���dSr)�close)r�exc_type�	exc_value�	tracebacks    r�__exit__zMySQLConnector.__exit__4s���
�
�����r�returnc�<�tjdi|j��|_|S)N�)rrrrrs rrzMySQLConnector.connect7s"��"�?�B�B�T�-A�B�B����r�Nonec�J�|j�|j���dSdSr)rr rs rr zMySQLConnector.close;s.����'���"�"�$�$�$�$�$�(�'rc�J�|j�|j���dSdSr)r�commitrs rr+zMySQLConnector.commit?s.����'���#�#�%�%�%�%�%�(�'rc�@�|j�|j��Sr)�
connection�cursorrrs rr.zMySQLConnector.cursorCs����%�%�d�&7�8�8�8rc�F�|j�|���|jSr)rrrs rr-zMySQLConnector.connectionFs!����#��L�L�N�N�N���rN�	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.
        )r2N)r-r.r�execute�fetchall)rr0r2r.s    r�
execute_queryzMySQLConnector.execute_queryLs����_�
#�
#�D�$5�
6�
6�	%�&��N�N�9�4�N�0�0�0��?�?�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	%�	%s�+A�A�Ar
r�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)r
rs  rrz+MySQLConnector.add_unix_socket_if_localhostTs=���;���=��#>�#>�$8�$:�$:�F�=�!�!�!���#>�#>r)F)r
r)r%r	)r%r(r)r0r1r2r3r%r4)r
r1rr9r%r()�__name__�
__module__�__qualname__rrr$rr r+r.�propertyr-r8�staticmethodrr'rrr	r	#s�������
&�
&�
&�
&�
&�����������%�%�%�%�&�&�&�&�9�9�9�� � ��X� �
%�%�%�%�%��;�;�;��\�;�;�;rr	c�P�t�|j|j��|S)zF
    Get a modified RFC 1738 URL for a MySQL database connection.
    )r	rr
�query)�urls r�get_rfc1738_db_urirEcs#���/�/���#�)�D�D�D��Jr)�plesk_config_path�
mysql_configsrFr1rG�
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)rFrG�psa_conf�psa_conf_socket�my_conf_path�my_conf�my_conf_sockets       rr<r<ks���
�w�~�~�'�(�(�#��.�#�>�>�>��"�,�,�~�6�6���&�"�"�%�"�"���w�~�~�l�+�+�	���L�t�<�<�<�� ���X�.�.���%�!�!�!�!�&�'�&r)rFr1rGrHr%r1)�
__future__rrO�typingrr�pymysql.cursorsr�ImportError�MySQLdb�MySQLdb.cursors�clcommon.clconfparsr�clcommon.cpapi.cpapiexceptionsr�PLESK_CONFIG_PATH�MY_CONFIG_PATH�MY_CONFIG_PATH2r	rEr<r'rr�<module>rbsi��#�"�"�"�"�"�	�	�	�	�������
+��N�N�N�+�*�*�*�*�*�*���/�/�/�/�!�!�!�!�	/�.�.�.�.�.�.����������������/����*�)�)�)�)�)�4�4�4�4�4�4�'����%��=;�=;�=;�=;�=;�=;�=;�=;�@���/�$2�O�#D�'�'�'�'�'�'�'�'s$��>�.�>�8�>�8�>�>