관리-도구
편집 파일: mysql_lib.cpython-311.pyc
� ����Zn$�4��������������������������d�dl�Z�d�dlmZmZ�d�dlmZ�d�dlZd�dlmZ�d�dl m Z �dZdZdZ �G�d ��d e������������Z�G�d��d������������Zd ��Zeee fd�dedee���������defd�Zdedee���������fd�Zdedee���������fd�ZdS�)�����N)�Iterable�List)�deque)� DictCursor)� load_fastz/etc/psa/psa.confz/etc/my.cnfz/etc/mysql/my.cnfc�������������������������e�Zd�ZdZdS�)� MySQLErrorz4 Exception related to operation with MySQL. N)�__name__� __module__�__qualname__�__doc__��������r/builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/clcommon/mysql_lib.pyr ���r ������s��������������������r���r ���c������������ ��������������e�Zd�Zddefd�Zd��Zd��Zd��Zdd�Zdd �Z dd�Z d��Zed ����������������Z �ddedee���������d z��deedf���������eeef���������z��fd�Zedededd fd���������������Zd S�)�MySQLConnectorF�as_dictc�����������������������|�����������������������|���������������������dd������������|�������������d�|�_��������|rt����������nd�|�_��������||�_��������d�S�)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������������������.�����|��������������������������������������d�S��N��close�r���s��� r����__del__zMySQLConnector.__del__&����������� � �����r���c������������������*�����|�������������������������������������S�r ���)�connectr#���s��� r���� __enter__zMySQLConnector.__enter__)���s�������|�|�~�~�r���c������������������.�����|��������������������������������������d�S�r ���r!���)r����exc_type� exc_value� tracebacks��� r����__exit__zMySQLConnector.__exit__,���r%���r����returnc�����������������������|�j����������|�S� �t����������j��������di�|�j����������|�_���������|�S�#�t����������j��������$�r"}t����������t ����������|������������������������|�d�}~ww�xY�w)Nr���)r����pymysqlr'���r����Errorr ����str)r����es��� r���r'���zMySQLConnector.connect/���sl��������'��K� ,�&��F�F��1E�F�F�D���K���}�� ,�� ,�� ,��S��V�V�$�$�!�+����� ,���s����(��A�A�ANc������������������X�����|�j����������"|�j���������������������������������������������d�|�_���������d�S�d�S�r ���)r���r"���r#���s��� r���r"���zMySQLConnector.close8���s6��������'���"�"�$�$�$�#�D�����(�'r���c������������������J�����|�j����������|�j���������������������������������������������d�S�d�S�r ���)r����commitr#���s��� r���r6���zMySQLConnector.commit=���s.��������'���#�#�%�%�%�%�%��(�'r���c������������������@�����|�j������������������������������|�j��������������������S�r ���)� connection�cursorr���r#���s��� r���r9���zMySQLConnector.cursorA���s��������%�%�d�&7�8�8�8r���c������������������F�����|�j����������|�������������������������������������|�j���������S�r ���)r���r'���r#���s��� r���r8���zMySQLConnector.connectionD���s!��������#��L�L�N�N�N���r���� sql_query�args.c������������������������|�j������������������������������|�j��������������������5�}|���������������������||��������������|�����������������������������������cddd�������������S�#�1�swxY�w�Y���dS�)z: Execute SQL query and return the result. )r<���N)r8���r9���r����execute�fetchall)r���r;���r<���r9���s��� r���� execute_queryzMySQLConnector.execute_queryJ���s���������_� #� #�D�$5� 6� 6�� %�&��N�N�9�4�N�0�0�0��?�?�$�$� %�� %�� %�� %�� %�� %�� %�� %�� %�� %�� %�� %����� %�� %�� %�� %�� %�� %s����+A�A�Ar���r���c������������������D�����|�dk����rd|vrt������������������������|d<���dS�dS�dS�)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���r���s��� r���r���z+MySQLConnector.add_unix_socket_if_localhostV���s=��������;���=��#>�#>�$8�$:�$:�F�=�!�!�!����#>�#>r���)F)r.���r���)r.���Nr ���)r ���r���r����boolr���r$���r(���r-���r'���r"���r6���r9����propertyr8���r2���r����object�tuple�dictr@����staticmethodr���r���r���r���r���r������sW�������������&��&���&��&��&��&����������������,��,��,��,�$��$��$��$� &��&��&��&�9��9��9��� �� ���X� ��)-� %�� %�� %���v���%� %�� �v�s�{� �d�3��;�/� /� %�� %�� %�� %���;�3��;���;���;��;��;���\�;��;��;r���r���c������������������P�����t��������������������������������|�j��������|�j���������������������|�S�)zF Get a modified RFC 1738 URL for a MySQL database connection. )r���r���r����query)�urls��� r����get_rfc1738_db_urirM���e���s#��������/�/���#�)�D�D�D��Jr���)�plesk_config_path� mysql_configsrN���rO���r.���c����������������������t�����������j�����������������������������|�������������r*t����������|�d�������������}|���������������������d������������}|�|S�t����������|������������}t ����������|������������dk����r�|�����������������������������������}t�����������j�����������������������������|������������s�Gt����������|d�������������}|���������������������d������������}|�|S�|���������������������t����������|�������������������������t ����������|������������dk������d S�) 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_SOCKETNr���T)�strip_quotes�socketz/var/lib/mysql/mysql.sock) �os�path�isfiler���r���r����len�popleft�extend� get_cnf_paths)rN���rO����psa_conf�psa_conf_socket�mysql_configs_queue�my_conf_path�my_conf�my_conf_sockets��� r���rC���rC���m���s������ �w�~�~�'�(�(��#��.�#�>�>�>��"�,�,�~�6�6���&�"�"�� �.�.�� �!� "� "�Q� &� &�*�2�2�4�4���w�~�~�l�+�+�� ���L�t�<�<�<�� ���X�.�.���%�!�!�� �"�"�=��#>�#>�?�?�?���!� "� "�Q� &� &��'�&r���rW���c����������������������g�}g�} �t����������|�ddd�������������5�}|D��] }|�����������������������������������} �|���������������������d������������r\|���������������������d�����������������������������������������������}t����������j�����������������������������|������������r|���������������������|�������������np|���������������������d������������r[|���������������������d�����������������������������������������������}t����������j�����������������������������|������������r|���������������������|���������������#�t����������$�r�Y���w�xY�w|D�]}|t����������|������������z ��}� �ddd�������������n#�1�swxY�w�Y���n/#�t����������t����������f$�r}t����������d |���d |���������������|�d}~ww�xY�w|S�)z� Get all included config files paths in the given config file marked with !include and !includedir. Returns an empty list if there are no paths. �rzutf-8�surrogateescape)�encoding�errorsz!includedirz !include z!includeNzError reading config file z: )�open�strip� startswith�removeprefixrV���rW����isdir�appendrX���� IndexError�get_cnf_files_in_dir�OSError�IOErrorr ���) rW����include_dirs� list_of_paths�config_file�line�included_dir_path�included_file_path�dir_pathr3���s ��� r���r\���r\�������s������!�L�!�M�J� �$��g�6G� H� H� H�� @�K�#�� �� ���z�z�|�|������}�5�5��E�,0�,=�,=�m�,L�,L�,R�,R�,T�,T�)��7�=�=�):�;�;��C�(�/�/�0A�B�B�B������5�5��E�-1�->�->�z�-J�-J�-P�-P�-R�-R�*��7�>�>�*<�=�=��E�)�0�0�1C�D�D�D���!��������D������)�� @�� @���!5�h�!?�!?�?� � � @� @�� @�� @�� @�� @�� @�� @�� @�� @�� @�� @����� @�� @�� @�� @���"� �W���J��J��J��A�d�A�A�a�A�A�B�B��I�����J�����s^����E��E�C!D�E� D$� E�#D$�$E�?E��E�E��E�E��F�(E>�>Fc����������������������g�}t�����������j�����������������������������|�������������r�t����������j��������|�������������D�]�}t�����������j�����������������������������t�����������j�����������������������������|�|������������������������r\t�����������j�����������������������������|������������d���������dk����r3|���������������������t�����������j�����������������������������|�|���������������������������|S�)zT Get paths list in given dir Returns an empty list if there is no paths ����z.cnf)rV���rW���rl����listdirrX����join�splitextrm���)rW���rs����items��� r���ro���ro�������s������� ��M� �w�}�}�T����?��J�t�$�$�� ?�� ?�D��w�~�~�b�g�l�l�4��6�6�7�7�� ?�B�G�<L�<L�T�<R�<R�ST�<U�Y_�<_�<_��$�$�R�W�\�\�$��%=�%=�>�>�>���r���)rV����typingr���r����collectionsr���r0����pymysql.cursorsr����clcommon.clconfparsr����PLESK_CONFIG_PATH�MY_CONFIG_PATH�MY_CONFIG_PATH2� Exceptionr ���r���rM���r2���rC����listr\���ro���r���r���r����<module>r�������s������ � � � ��!��!��!��!��!��!��!��!�������������������&��&��&��&��&��&��)��)��)��)��)��)�'�����%������������������E;��E;��E;��E;��E;��E;��E;��E;�P������/�$2�O�#D� '�� '�� '�� '���C�=� '�� � '�� '�� '�� '�F�����S� ���������B �s�� �t�C�y�� �� �� �� �� �� r���