403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.11/site-packages/pymysql/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.11/site-packages/pymysql/__pycache__/connections.cpython-311.pyc
�

���_3��	��ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
mZmZmZmZddlmZddlmZddlmZdd	lmZmZmZmZmZmZdd
lmZmZ	ddl Z dZ!n#e"$rdZ dZ!YnwxYw	ddl#Z#e#j$��Z%[#n#e"e&f$rdZ%YnwxYwdZ'ej(ej)ej*ej+ej,ej-ej.ej/ej0h	Z1d
Z2dZ3d�Z4d�Z5Gd�d��Z6Gd�d��Z7Gd�d��Z8dS)�N�)�_auth)�charset_by_name�
charset_by_id)�CLIENT�COMMAND�CR�
FIELD_TYPE�
SERVER_STATUS)�
converters)�Cursor)�Parser)�dump_packet�MysqlPacket�FieldDescriptorPacket�OKPacketWrapper�EOFPacketWrapper�LoadLocalPacketWrapper)�err�VERSION_STRINGTF�utf8mb4��c�<�tjd|��dd�S)N�<I�)�struct�pack)�ns �8/usr/lib/python3.11/site-packages/pymysql/connections.py�_pack_int24r Cs���;�t�Q������#�#�c�J�|dkrtd|z���|dkrt|g��S|dkrdtjd|��zS|dkr dtjd	|��dd
�zS|dkrdtjd
|��zStd|dfz���)NrzFEncoding %d is less than 0 - no representation in LengthEncodedInteger�i���<H���rrl��z<QzIEncoding %x is larger than %x - no representation in LengthEncodedInteger)�
ValueError�bytesrr)�is r�_lenenc_intr,Hs����1�u�u��T�WX�X�
�
�	
�
�T����a�S�z�z��	
�g������T�1�-�-�-�-�	
�g������T�1�-�-�b�q�b�1�1�1�	
�g������T�1�-�-�-�-��W��7�n�
�
�
�	
r!c'�,�eZdZdZdZdZdZdZddddddddddddedddddddddddddddddddddddddd	�&d
�Z	d�Z
d�Zd
�Zd�Z
ed���Zd�ZeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd6d�Zd�Zd�Zd�Zd6d�Zd7d�Z d7d �Z!d!�Z"d"�Z#d8d#�Z$d$�Z%d6d%�Z&d&�Z'e(fd'�Z)d(�Z*d)�Z+d7d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6d5�Z7e8j9Z9e8j:Z:e8j;Z;e8j<Z<e8j=Z=e8j>Z>e8j?Z?e8j@Z@e8jAZAe8jBZBdS)9�
ConnectionaP
    Representation of a socket with a mysql server.

    The proper way to get an instance of this class is to call
    connect().

    Establish a connection to the MySQL database. Accepts several
    arguments:

    :param host: Host where the database server is located
    :param user: Username to log in as
    :param password: Password to use.
    :param database: Database to use, None to not use a particular one.
    :param port: MySQL port to use, default is usually OK. (default: 3306)
    :param bind_address: When the client has multiple network interfaces, specify
        the interface from which to connect to the host. Argument can be
        a hostname or an IP address.
    :param unix_socket: Optionally, you can use a unix socket rather than TCP/IP.
    :param read_timeout: The timeout for reading from the connection in seconds (default: None - no timeout)
    :param write_timeout: The timeout for writing to the connection in seconds (default: None - no timeout)
    :param charset: Charset you want to use.
    :param sql_mode: Default SQL_MODE to use.
    :param read_default_file:
        Specifies  my.cnf file to read these parameters from under the [client] section.
    :param conv:
        Conversion dictionary to use instead of the default one.
        This is used to provide custom marshalling and unmarshalling of types.
        See converters.
    :param use_unicode:
        Whether or not to default to unicode strings.
        This option defaults to true.
    :param client_flag: Custom flags to send to MySQL. Find potential values in constants.CLIENT.
    :param cursorclass: Custom cursor class to use.
    :param init_command: Initial SQL statement to run when connection is established.
    :param connect_timeout: Timeout before throwing an exception when connecting.
        (default: 10, min: 1, max: 31536000)
    :param ssl:
        A dict of arguments similar to mysql_ssl_set()'s parameters.
    :param ssl_ca: Path to the file that contains a PEM-formatted CA certificate
    :param ssl_cert: Path to the file that contains a PEM-formatted client certificate
    :param ssl_disabled: A boolean value that disables usage of TLS
    :param ssl_key: Path to the file that contains a PEM-formatted private key for the client certificate
    :param ssl_verify_cert: Set to true to check the validity of server certificates
    :param ssl_verify_identity: Set to true to check the server's identity
    :param read_default_group: Group to read from in the configuration file.
    :param autocommit: Autocommit mode. None means use server default. (default: False)
    :param local_infile: Boolean to enable the use of LOAD DATA LOCAL command. (default: False)
    :param max_allowed_packet: Max size of packet sent to server in bytes. (default: 16MB)
        Only used to limit size of "LOAD LOCAL INFILE" data packet smaller than default (16KB).
    :param defer_connect: Don't explicitly connect on construction - wait for connect call.
        (default: False)
    :param auth_plugin_map: A dict of plugin names to a class that processes that plugin.
        The class will take the Connection object as the argument to the constructor.
        The class needs an authenticate method taking an authentication packet as
        an argument.  For the dialog plugin, a prompt(echo, prompt) method can be used
        (if no authenticate method) for returning a string from the user. (experimental)
    :param server_public_key: SHA256 authentication plugin public key value. (default: None)
    :param binary_prefix: Add _binary prefix on bytes and bytearray. (default: False)
    :param compress: Not supported
    :param named_pipe: Not supported
    :param db: **DEPRECATED** Alias for database.
    :param passwd: **DEPRECATED** Alias for password.

    See `Connection <https://www.python.org/dev/peps/pep-0249/#connection-objects>`_ in the
    specification.
    N�FrT�
r&)&�user�password�host�database�unix_socket�port�charset�sql_mode�read_default_file�conv�use_unicode�client_flag�cursorclass�init_command�connect_timeout�read_default_group�
autocommit�local_infile�max_allowed_packet�
defer_connect�auth_plugin_map�read_timeout�
write_timeout�bind_address�
binary_prefix�program_name�server_public_key�ssl�ssl_ca�ssl_cert�ssl_disabled�ssl_key�ssl_verify_cert�ssl_verify_identity�compress�
named_pipe�passwd�dbc&���*�|&�|�|&}|%�|s|%}|#s|$rtd���t|��|_|jr|tjz}�r&|	s$t
j�d��rd}	nd}	|	r��sd�t���*�*�	tj�|	�����*�fd�}'|'d|��}|'d|��}|'d	|��}|'d
|��}|'d|��}t|'d|����}|'d
|��}|'d|��}|si}t|t��r)dD]&}(|'d|(z|j|(����})|)r|)||(<�'d|_|sw|s|s| s|!s|"r%|t|"��|!�|!ndd�}|�||d<| �| |d<|rFt$std���d|_|tjz}|�|��|_|pd|_|pd|_t1|j��turt3d���|pt4|_|pd|_t|jt:��r|j�d��|_||_||_ ||_!d|cxkrdksnt3d���|pd|_"|�|dkrt3d���||_#|�|dkrt3d ���||_$|ptJ|_&||_'tQ|j&��j)|_)|tj*z}|jr|tj+z}||_,|
|_-d|_.d|_/d!|_0||_1|
�tdj3}
d"�|
�4��D��|_5d#�|
�4��D��|_6||_7||_8||_9|pi|_:||_;||_<d$t;tj=����t|d%�|_?|r
||j?d&<|r	d|_@dS|�A��dS)'Nz3compress and named_pipe arguments are not supported�winz	c:\my.iniz/etc/my.cnf�clientc�^��|r|S	���|��S#t$r|cYSwxYw�N)�get�	Exception)�key�arg�cfgr@s  ��r�_configz$Connection.__init__.<locals>._config�sN������J���7�7�#5�s�;�;�;�� �����J�J�J����s��,�,r1r2r3r4�socketr6zbind-addresszdefault-character-set)�ca�capath�certr^�cipherzssl-F)rc�check_hostname�verify_moderer^zssl module not foundT�	localhosti�zport should be of type intr!�latin1ri�3�z+connect_timeout should be >0 and <=31536000zread_timeout should be > 0zwrite_timeout should be > 0z
Not connectedc�F�i|]\}}t|��tu�||��S���type�int��.0�k�vs   r�
<dictcomp>z'Connection.__init__.<locals>.<dictcomp>Ls.��O�O�O�&�1�a�D��G�G�3�<N�<N��A�<N�<N�<Nr!c�F�i|]\}}t|��tu�||��Srlrmrps   rrtz'Connection.__init__.<locals>.<dictcomp>Ms)��K�K�K�&�1�a�D��G�G�s�N�N��A�N�N�Nr!�pymysql)�_client_name�_pid�_client_versionrJ)B�NotImplementedError�bool�
_local_infiler�LOCAL_FILES�sys�platform�
startswithr�read�os�path�
expanduserro�
isinstance�dictr\rL�SSL_ENABLED�SSL�_create_ssl_ctx�ctxr3r6rnr)�DEFAULT_USERr1r2�str�encoderVr5rHr?�
_read_timeout�_write_timeout�DEFAULT_CHARSETr7r;r�encoding�CAPABILITIES�CONNECT_WITH_DBr<r=�_result�_affected_rows�	host_info�autocommit_moder�conversions�items�encoders�decodersr8r>rC�_auth_plugin_map�_binary_prefixrK�getpidr�_connect_attrs�_sock�connect)+�selfr1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrUrVrar^�valuer`s+                `                         @r�__init__zConnection.__init__�s@����T�>�h�.��H���h���H��	�z�	�%�E���
�"�,�/�/�����	.��6�-�-�K��	2�&7�	2��|�&�&�u�-�-�
2�$0�!�!�$1�!��	)�%�
.�%-�"��(�(�C��H�H�R�W�'�'�(9�:�:�;�;�;�
�
�
�
�
�
��7�6�4�(�(�D��w�z�8�4�4�H��7�6�4�(�(�D��w�z�8�4�4�H�!�'�(�K�8�8�K��w�w�v�t�,�,�-�-�D�"�7�>�<�@�@�L��g�5�w�?�?�G��
����#�t�$�$�
)�D�)�)�C�#�G�F�S�L�'�#�'�#�,�,�?�?�E��)�#(��C�������	5��
)��
)�W�
)��
)�CV�
)� �&*�+>�&?�&?�&�2�$3�?������'�"*�C��K��&�!(�C��J��
5�"�F�-�.D�E�E�E�����v�z�)���/�/��4�4����'�K��	��L�D��	���	�?�?�#�%�%��9�:�:�:��(�L��	� ��C��
��d�m�S�)�)�	;� �M�0�0��:�:�D�M����&���(����O�/�/�/�/�x�/�/�/�/��J�K�K�K�.�6�$����#���(9�(9��9�:�:�:�)����$��!�);�);��:�;�;�;�+����1�/���&���'���5�5�>��
��v�*�*���7�	2��6�1�1�K�&���&���������(��� *����<��)�D�P�O�D�J�J�L�L�O�O�O��
�K�K�D�J�J�L�L�K�K�K��
� ��
�(���"4��� /� 5�2���+���!2���&���	���$�$�-�
�
����	?�2>�D���/��	��D�J�J�J��L�L�N�N�N�N�Nr!c��|Sr[rl�r�s r�	__enter__zConnection.__enter__cs���r!c�0�~|���dSr[)�close)r��exc_infos  r�__exit__zConnection.__exit__fs����
�
�����r!c��t|tj��r|S|�d��}|�d��}|duo|du}tj||���}|o|�dd��|_|�d��}|� |rtjntj|_n�t|t��r |rtjntj|_n�t|t��r|���}|dvrtj|_nM|dkrtj|_n5|d	vrtj|_n|rtjntj|_d
|vr0|�
|d
|�d�����d
|vr|�|d
��|xjtjzc_|xjtjzc_|S)Nrcrd)�cafilerdrgTrh)�none�0�false�no�optional)�required�1�true�yesrer^)�keyfilerf)r�rL�
SSLContextr\�create_default_contextrg�	CERT_NONE�
CERT_REQUIREDrhr{r��lower�
CERT_OPTIONAL�load_cert_chain�set_ciphers�options�OP_NO_SSLv2�OP_NO_SSLv3)r��sslprcrd�hasnocar��verify_mode_values       rr�zConnection._create_ssl_ctxjs����d�C�N�+�+�	��K�
�X�X�d�^�^�����(�#�#����*�/��4����(��6�B�B�B��!(�[�M�T�X�X�6F��-M�-M��� �H�H�]�3�3���$�/6�M�c�m�m�C�<M�C�O�O�
�)�4�
0�
0�	R�3D�W�c�/�/�#�-�C�O�O��+�S�1�1�
>�$5�$;�$;�$=�$=�!� �$@�@�@�"%�-����"�j�0�0�"%�"3����"�&F�F�F�"%�"3����3:�"Q�#�-�-��@Q����T�>�>�����V��d�h�h�u�o�o��F�F�F��t����O�O�D��N�+�+�+����s��&������s��&����
r!c�D�|jrtjd���d|_|j�dSt	jddtj��}	|�|��n#t$rYnwxYw|�
��dS#|�
��wxYw)z�
        Send the quit message and close the socket.

        See `Connection.close() <https://www.python.org/dev/peps/pep-0249/#Connection.close>`_
        in the specification.

        :raise Error: If the connection is already closed.
        �Already closedTN�<iBr)�_closedr�Errorr�rrr�COM_QUIT�_write_bytesr]�_force_close)r��	send_datas  rr�zConnection.close�s����<�	.��)�,�-�-�-�����:���F��K��q�'�*:�;�;�	�	 ����i�(�(�(�(���	�	�	��D�	����
���������D���������s*�
A#�"B	�#
A0�-B	�/A0�0B	�	Bc��|jduS)z%Return True if the connection is openN)r�r�s r�openzConnection.open�s���z��%�%r!c�t�|jr"	|j���n#YnxYwd|_d|_dS)z%Close connection without QUIT messageN)r�r��_rfiler�s rr�zConnection._force_close�sH���:�	�
��
� � �"�"�"�"��
��������
�����s�#�'c��t|��|_|���}||kr|���dSdSr[)r{r��get_autocommit�_send_autocommit_mode)r�r��currents   rrAzConnection.autocommit�sL��#�E�{�{����%�%�'�'���G����&�&�(�(�(�(�(��r!c�D�t|jtjz��Sr[)r{�
server_statusr�SERVER_STATUS_AUTOCOMMITr�s rr�zConnection.get_autocommit�s���D�&��)O�O�P�P�Pr!c��|���}|���stjdd���t	|��}|j|_|S)N��zCommand Out of Sync)�_read_packet�is_ok_packetr�OperationalErrorrr�)r��pkt�oks   r�_read_ok_packetzConnection._read_ok_packet�sY�����!�!�����!�!�	D��&�t�-B�C�C�C�
�S�
!�
!���-����	r!c��|�tjd|�|j��z��|���dS)z2Set whether or not to commit after every execute()zSET AUTOCOMMIT = %sN)�_execute_commandr�	COM_QUERY�escaper�r�r�s rr�z Connection._send_autocommit_mode�sQ�������4�t�{�{�4�CW�7X�7X�X�	
�	
�	
�	
�������r!c�n�|�tjd��|���dS)zBegin transaction.�BEGINN�r�rr�r�r�s r�beginzConnection.begin�s3�����g�/��9�9�9��������r!c�n�|�tjd��|���dS)z�
        Commit changes to stable storage.

        See `Connection.commit() <https://www.python.org/dev/peps/pep-0249/#commit>`_
        in the specification.
        �COMMITNr�r�s r�commitzConnection.commit�s5��	
���g�/��:�:�:��������r!c�n�|�tjd��|���dS)z�
        Roll back the current transaction.

        See `Connection.rollback() <https://www.python.org/dev/peps/pep-0249/#rollback>`_
        in the specification.
        �ROLLBACKNr�r�s r�rollbackzConnection.rollback�s5��	
���g�/��<�<�<��������r!c��|�tjd��t|��}|���|jS)z%Send the "SHOW WARNINGS" SQL command.z
SHOW WARNINGS)r�rr��MySQLResultr��rows)r��results  r�
show_warningszConnection.show_warnings�s=�����g�/��A�A�A��T�"�"�����
�
�
��{�r!c�n�|�tj|��|���dS)zI
        Set current db.

        :param db: The name of the db.
        N)r�r�COM_INIT_DBr�)r�rVs  r�	select_dbzConnection.select_db�s5��	
���g�1�2�6�6�6��������r!c��t|t��rd|�|��zdzSt|ttf��r#|�|��}|jrd|z}|Stj||j	|���S)z}Escape whatever value you pass to it.

        Non-standard, for internal use; do not use this in your applications.
        �'�_binary)�mapping)
r�r��
escape_stringr*�	bytearray�_quote_bytesr�r�escape_itemr7)r��objr��rets    rr�zConnection.escape�s���
�c�3���	7���+�+�C�0�0�0�3�6�6��c�E�9�-�.�.�	��#�#�C�(�(�C��"�
&��#�o���J��%�c�4�<��I�I�I�Ir!c�8�|�||j��S)zjAlias for escape()

        Non-standard, for internal use; do not use this in your applications.
        )r�r�)r�rs  r�literalzConnection.literals��
�{�{�3��
�.�.�.r!c�~�|jtjzr|�dd��St	j|��S)Nr�z'')r�r�"SERVER_STATUS_NO_BACKSLASH_ESCAPES�replacerr��r��ss  rr�zConnection.escape_strings:����
� P�P�	(��9�9�S�$�'�'�'��'��*�*�*r!c��|jtjzr.d|�dd���dd���d�Stj|��S)Nr��'s''�ascii�surrogateescape)r�rrr�decoder�escape_bytesrs  rr�zConnection._quote_bytess[����
� P�P�	Y�	Y��Y�Y�t�U�3�3�:�:�7�DU�V�V�V�V�X�X��&�q�)�)�)r!c�F�|r||��S|�|��S)a	
        Create a new cursor to execute queries with.

        :param cursor: The type of cursor to create; one of :py:class:`Cursor`,
            :py:class:`SSCursor`, :py:class:`DictCursor`, or :py:class:`SSDictCursor`.
            None means use Cursor.
        )r=)r��cursors  rrzConnection.cursors.���	 ��6�$�<�<������%�%�%r!c���t|t��r|�|jd��}|�t
j|��|�|���|_|jS)Nr��
unbuffered)	r�r�r�r�r�rr��_read_query_resultr�)r��sqlrs   r�queryzConnection.querysg���c�3���	?��*�*�T�]�,=�>�>�C����g�/��5�5�5�"�5�5��5�L�L����"�"r!c�F�|�|���|_|jS)Nr)rr�)r�rs  r�next_resultzConnection.next_result's$��"�5�5��5�L�L����"�"r!c��|jSr[)r�r�s r�
affected_rowszConnection.affected_rows+����"�"r!c��tjd|��}|�tj|��|���S)Nr)rrr�r�COM_PROCESS_KILLr�)r��	thread_idr_s   r�killzConnection.kill.s>���k�$�	�*�*�����g�6��<�<�<��#�#�%�%�%r!c�R�|j�-|r|���d}ntjd���	|�t
jd��|���dS#t$r0|r,|���|�	d��YdS�wxYw)z�
        Check if the server is alive.

        :param reconnect: If the connection is closed, reconnect.
        :raise Error: If the connection is closed and reconnect=False.
        NFr�r/)
r�r�rr�r�r�COM_PINGr�r]�ping)r��	reconnects  rr"zConnection.ping3s����:���
2�������!�	�	��i� 0�1�1�1�	��!�!�'�"2�B�7�7�7�� � �"�"�"�"�"���	�	�	��
��������	�	�%� � � � � � ��	���s�4A,�,5B&�$B&c���t|��j}|�tjd|�|��z��|���||_||_dS)NzSET NAMES %s)rr�r�rr�r�r�r7)r�r7r�s   r�set_charsetzConnection.set_charsetJs`��"�7�+�+�4�����g�/��$�+�+�g�BV�BV�1V�W�W�W���������� ��
�
�
r!c	���d|_	|���|jr�tjtjtj��}|�|j��|�|j��d|_d|_	trtd��n�i}|j�|jdf|d<		tj
|j|jf|jfi|��}n4#t t"f$r }|jt$jkrYd}~�R�d}~wwxYwd|j|jfz|_trtd��|�tjtjd	��|�tjtjd	��|�d��||_|�d
��|_d|_|���|���|j�0|� ��}|�!d|jf��|j"�V|� ��}|�!|j"��|�#��|�$��|j%�|�&|j%��dSdS#tN$r�}d|_|�	|�#��n#YnxYwtQ|t t"tj)f��r]tUj+dd
|j�d|�d���}||_,t[j.��|_-trt|j-��|��d}~wwxYw)NFzLocalhost via UNIX socketTzconnected using unix_socketr�source_addresszsocket %s:%dzconnected using socketr�rbzSET sql_mode=%si�z!Can't connect to MySQL server on z (�))/r�r5rb�AF_UNIX�SOCK_STREAM�
settimeoutr?r�r��_secure�DEBUG�printrH�create_connectionr3r6�OSError�IOError�errno�EINTR�
setsockopt�IPPROTO_TCP�TCP_NODELAY�
SOL_SOCKET�SO_KEEPALIVEr��makefiler��_next_seq_id�_get_server_information�_request_authenticationr8r�executer>r�r�r�rA�
BaseExceptionr��errorrr��original_exception�	traceback�
format_exc)r��sock�kwargs�e�c�excs      rr�zConnection.connectSsU�����H	��|��#�O�!�=����9K�L�L�D��O�O�D�$8�9�9�9��L�L��!1�2�2�2�%@�D�N�#'�D�L��=��;�<�<�<���F��(�4�48�4E�q�3I��/�0�	"�"�#)�#;�!%��D�I� 6��8L�$�$�PV�$�$�D�"�� '��1�"�"�"� �w�%�+�5�5� (�����!�����"����&4�t�y�$�)�6L�%L�D�N��8��6�7�7�7��O�O�F�$6��8J�A�N�N�N��O�O�F�$5�v�7J�A�N�N�N�����%�%�%��D�J��-�-��-�-�D�K� !�D���(�(�*�*�*��(�(�*�*�*��}�(��K�K�M�M���	�	�+�d�m�-=�>�>�>�� �,��K�K�M�M���	�	�$�+�,�,�,����	�	�	����
�
�
��#�/����� 4�5�5�5�5�5�0�/���	�	�	��D�K�����J�J�L�L�L�L����D�����!�g�w���=�>�>�	
��*��D��	�	�	�ST�ST�ST�U����*+��&� )� 4� 6� 6��
��)��#�-�(�(�(��	�

�����-	���sb�B"J%�,$C�J%�D�"C=�7J%�<C=�=D�FJ%�%
M�/	M�9K�
M�K�B
M�Mc���tt|����t|jg��z|z}trt|��|�|��|jdzdz|_dS)zvWrites an entire "mysql packet" in its entirety to the network
        adding its length and sequence number.
        r�N)r �lenr*r;r.rr�)r��payload�datas   r�write_packetzConnection.write_packet�st���3�w�<�<�(�(�5�$�2C�1D�+E�+E�E��O���	���������$����!�.��2�c�9����r!c���t��}	|�d��}tjd|��\}}}||dzz}||jkrW|���|dkrt
jtj	d���t
j
d||jfz���|jdzd	z|_|�|��}trt|��||z
}|d
kr��|tkrn��|t|��|j��}	|	���r5|j�|jjdurd|j_|	���|	S)
a!Read an entire "mysql packet" in its entirety from the network
        and return a MysqlPacket type that represents the results.

        :raise OperationalError: If the connection to the MySQL server is lost.
        :raise InternalError: If the packet sequence number is wrong.
        T�z<HBB�r�,Lost connection to MySQL server during queryz1Packet sequence number wrong - got %d expected %drrJrNF)r��_read_bytesr�unpackr;r�rr�r	�CR_SERVER_LOST�
InternalErrorr.r�MAX_PACKET_LENr*r��is_error_packetr��unbuffered_active�raise_for_error)
r��packet_type�buff�
packet_header�btrl�btrh�
packet_number�
bytes_to_read�	recv_data�packets
          rr�zConnection._read_packet�s����{�{��	� �,�,�Q�/�/�M�)/�
�f�m�(L�(L�%�D�$�
� �D�B�J�/�M��� 1�1�1��!�!�#�#�#� �A�%�%��.��)�F�����'�G�$�d�&7�8�9����"&�!2�Q�!6�#� =�D���(�(��7�7�I��
'��I�&�&�&��I��D���(�(���~�-�-��9	�<��U�4�[�[�$�-�8�8���!�!�#�#�	%��|�'�D�L�,J�d�,R�,R�16���.��"�"�$�$�$��
r!c��|j�|j��		|j�|��}n�#t
tf$rV}|jtjkrYd}~�H|�	��tjtj
d|�d����d}~wt$r|�	���wxYwt|��|kr3|�	��tjtj
d���|S)NTz.Lost connection to MySQL server during query (r)rR)r�r,r�r�r�r2r1r3r4r�rr�r	rUr?rK)r��	num_bytesrMrFs    rrSzConnection._read_bytes�s(���
���d�0�1�1�1�	�
��{�'�'�	�2�2�����W�%�
�
�
��7�e�k�)�)��H�H�H�H��!�!�#�#�#��*��%�%�KL�1�1�N��������!�
�
�
��!�!�#�#�#��
�����t�9�9�y� � ��������&��!�#Q���
��s�=�C�B�(7B�#Cc��|j�|j��	|j�|��dS#t$r<}|���t
jtj	d|�d����d}~wwxYw)NzMySQL server has gone away (r))
r�r,r��sendallr2r�rr�r	�CR_SERVER_GONE_ERROR)r�rMrFs   rr�zConnection._write_bytes�s����
���d�1�2�2�2�	��J���t�$�$�$�$�$���	�	�	��������&��'�'�a�a�a�)Q���
�����	���s�=�
B�7A>�>Bc��d|_|r9	t|��}|���n7#d|_d|_�xYwt|��}|���||_|j�|j|_|jS�NF)r�r��init_unbuffered_queryrY�
connectionr�r�r)r�rr�s   rrzConnection._read_query_result�s�������
	�
�$�T�*�*���,�,�.�.�.�.��
�+0��(�$(��!����� ��&�&�F��K�K�M�M�M������+�!'�!5�D���#�#s	�#/�Ac�,�|jr|jjSdS�Nr)r��	insert_idr�s rrozConnection.insert_id
s���<�	��<�)�)��1r!c�`�|jstjdd���|j�l|jjr-tjd��|j���|jjr |�	��|jj� d|_t|t��r|�|j
��}ttt!|��dz��}t#jd||��}||d|dz
�z}|�|��t(rt+|��d|_|tkrdS||dz
d�}	ttt!|����}|�|d|���||d�}|s
|tkrdS�Y)z~
        :raise InterfaceError: If the connection is closed.
        :raise ValueError: If no username was specified.
        rr/Nz.Previous unbuffered result was left incompleterr�)r�r�InterfaceErrorr�rY�warnings�warn�_finish_unbuffered_query�has_nextrr�r�r�r��minrWrKrrr�r.rr;rN)r��commandr�packet_size�preludercs      rr�zConnection._execute_commands���
�z�	,��$�Q��+�+�+��<�#��|�-�
8��
�N�O�O�O���5�5�7�7�7��,�'�
#�� � �"�"�"��,�'�
#��D�L��c�3���	,��*�*�T�]�+�+�C��.�#�c�(�(�Q�,�7�7���+�e�[�'�:�:���3�0��q��0�1�1�����&�!�!�!��	 �����������'�'��F��+��/�#�#�$��	��n�c�#�h�h�7�7�K����c�,�;�,�/�0�0�0��k�l�l�#�C��
�;��7�7���	r!c��t|j�dd��d��dkr|xjtjzc_|j�td���t|j	��j
}t|jt��r$|j�
|j��|_tjd|jt"|d��}|jrz|jtjzrf|�|��|j�|j|j���|_|j�d	��|_d
|_||jzdz}d}d}|jdkr"d}t=j|j |j!��}n�|jd
kr"d}t=j|j |j!��}n�|jdkrVd}|j r6tDrtGd��t=j$|j |j!��}nVtDrtGd��n?|jdkr4d}|jr|jtjzr|j dz}n|j rd}nd}|jtj%zr#|tMtO|����|zz
}nE|jtj(zr)|tjdtO|����|zz
}n||dzz
}|j)r_|jtj*zrKt|j)t��r$|j)�
|j��|_)||j)dzz
}|jtj+zr
||pddzz
}|jtj,zr�d}|j-�.��D]\}}|�
d��}|tjdtO|����|zz
}|�
d��}|tjdtO|����|zz
}��|tjdtO|����|zz
}|�|��|�/��}	|	�0��r�tDrtGd��|	�1��|	�2��}|jtj+zr|�|�3||	��}	n�t=j4|j |j!��dz}|�|��|�/��}	n�|	�5��rrtDrtGd��|jdkrt=j6||	��}	n;|jdkrt=j7||	��}	ntqj9d|j���tDrtGd��dSdS)N�.rr�zDid not specify a usernamez<iIB23sr!)�server_hostnamer(T�r/�mysql_native_password�mysql_native_password�caching_sha2_password�caching_sha2_passwordzcaching_sha2: trying fast pathzcaching_sha2: empty password�sha256_password�sha256_password��B�utf-8zreceived auth switchzreceived extra dataz(Received extra packet for auth method %rzSucceed to auth):ro�server_version�splitr<r�
MULTI_RESULTSr1r)rr7�idr�r�r�r�rrrWrL�server_capabilitiesr�rNr��wrap_socketr�r3r:r�r-�_auth_plugin_namer�scramble_native_passwordr2�saltr.r/�scramble_caching_sha2�PLUGIN_AUTH_LENENC_CLIENT_DATAr,rK�SECURE_CONNECTIONrVr��PLUGIN_AUTH�
CONNECT_ATTRSr�r�r��is_auth_switch_request�
read_uint8�read_string�
_process_auth�scramble_old_password�is_extra_auth_data�caching_sha2_password_auth�sha256_password_authrr�)
r��
charset_id�	data_initrM�authresp�plugin_name�
connect_attrsrrrs�auth_packets
          rr=z"Connection._request_authentication>s����t�"�(�(��a�0�0��3�4�4��9�9����� 4�4����9���9�:�:�:�$�T�\�2�2�5�
��d�i��%�%�	8��	�(�(���7�7�D�I��K��t�'���S�
�
�	��8�	 ��0�6�:�=�	 ����i�(�(�(���-�-�d�j�$�)�-�T�T�D�J��*�-�-�d�3�3�D�K��D�L��4�9�$�u�,�������!�R�'�'��K��5�d�m�T�Y�O�O�H�H�
�
#�'>�
>�
>�2�K��5�d�m�T�Y�O�O�H�H�
�
#�'>�
>�
>�2�K��}�
:��<��:�;�;�;� �6�t�}�d�i�P�P����:��8�9�9�9��
�
#�'8�
8�
8�,�K��x�
!�D�4�v�z�A�
!��=�5�0�����
!� ��� ���#�f�&K�K�	%��K��H�
�
�.�.��9�9�D�D�
�
%��(@�
@�	%��F�K��S��]�]�3�3�h�>�>�D�D��H�u�$�$�D��7�	$�t�/�&�2H�H�	$��$�'�3�'�'�
8��'�.�.���7�7����D�G�e�O�#�D��#�f�&8�8�	1��[�'�C�5�0�0�D��#�f�&:�:�	I��M��+�1�1�3�3�
>�
>���1��H�H�W�%�%�����S�#�a�&�&�!9�!9�A�!=�=�
��H�H�W�%�%�����S�#�a�&�&�!9�!9�A�!=�=�
�
��F�K��S��%7�%7�8�8�=�H�H�D����$�����'�'�)�)���-�-�/�/�	��
.��,�-�-�-��"�"�$�$�$�%�1�1�3�3�K��(�6�+=�=�	
2��+�"�0�0��k�J�J����2�4�=�$�)�L�L�u�T���!�!�$�'�'�'�"�/�/�1�1���
�
+�
+�
-�
-�	��
-��+�,�,�,��%�)@�@�@�#�>�t�[�Q�Q����'�+<�<�<�#�8��{�K�K����*�>��@V�����	%��#�$�$�$�$�$�	%�	%r!c���|�|��}|rU	|�|��S#t$r2|dkr)tjdd|�dt|���d����YnwxYw|dkrt
j||��S|dkrt
j||��S|dkr.t
j	|j
|�����}�n�|d	kr.t
j|j
|�����}�n�|d
kr1t
j
|j
|�����dz}�ny|dkr|j
dz}�ng|dk�rH|}	|���}|dzdk}|dzdk}|���}	|	dkr|�|j
dz��n�|r�d}
	|�||	��}
|�|
dz��np#t$rtjdd|�d|�d����t"$r"tjdd|�d|�d|
�d|	�����wxYwtjdd|�d|�d����|���}|���|���s|rn��C|Stjdd|z���|�|��|���}|���|S)Nsdialog��Authentication plugin '�' not loaded: - z missing authenticate methodr�r�r�sclient_ed25519smysql_old_passwordr~smysql_clear_passwordT��rs
Password: z3no response - TypeError within plugin.prompt methodz missing prompt methodi
z' z' didn't respond with string. Returned 'z' to prompt z' (z) not configuredz)Authentication plugin '%s' not configured)�_get_auth_plugin_handler�authenticate�AttributeErrorrr�rnrr�r�r�r2�read_all�ed25519_passwordr�r�rN�prompt�	TypeErrorr��check_errorr�)r�r�r��handlerrMr��flag�echo�lastr��resps           rr�zConnection._process_auth�s����/�/��<�<���
	�	
��+�+�K�8�8�8��!�
�
�
��)�+�+��.���'�;�;��W�
�
�
�
�7����,�+�
�����2�2�2��3�D�+�F�F�F�
�.�
.�
.��-�d�K�@�@�@�
�4�
4�
4��1�$�-��AU�AU�AW�AW�X�X�D�D�
�-�
-�
-��)�$�-��9M�9M�9O�9O�P�P�D�D�
�1�
1�
1��+�D�M�;�;O�;O�;Q�;Q�R�R���
�D��3�
3�
3��=�5�(�D�D�
�I�
%�
%��C�$
��~�~�'�'���t���,���t���,���������]�*�*��%�%�d�m�e�&;�<�<�<�<���P�D��&�~�~�d�F�;�;���)�)�$��,�7�7�7�7��)����!�2� �D� +�{�{�G�G�G�5����%����!�2� �D� +�{�{�G�G�G�T�T�T�6�6�C���������.���&�;�;����1����
�'�'�)�)�����!�!�!��#�#�%�%�����I$
�J�J��&��A�K�O���
�	
���$�������!�!���������
s�.�9A*�)A*�.G0�0AIc	�8�|j�|��}|sBt|t��r-|j�|�d����}|r7	||��}n,#t
$rt
jdd|�d|�d����wxYwd}|S)Nrr�r�r�z- cannot be constructed with connection object)r�r\r�r*r
r�rr�)r�r��plugin_classr�s    rr�z#Connection._get_auth_plugin_handler�s����,�0�0��=�=���	R�
�;�� >� >�	R��0�4�4�[�5G�5G��5P�5P�Q�Q�L��	�
�&�,�t�,�,�����
�
�
��*��D�#�{�{�L�L�L�2����
�����G��s�"A.�.'Bc��|jdSrn)�server_thread_idr�s rrzConnection.thread_ids���$�Q�'�'r!c��|jSr[)r7r�s r�character_set_namezConnection.character_set_names
���|�r!c��|jSr[)r�r�s r�
get_host_infozConnection.get_host_infos
���~�r!c��|jSr[)�protocol_versionr�s r�get_proto_infozConnection.get_proto_infos���$�$r!c� �d}|���}|���}|||_|dz
}|�d|��}|||��d��|_|dz}t
jd|||dz���|_|dz
}|||dz�|_	|dz
}t
jd	|||d
z���d|_
|d
z
}t|��|dzkr�t
jd|||dz���\}}}}|dz
}||_	t|��j|_n#t $r
d|_YnwxYw||_t$rt'd
|z��|xj
|dzzc_
t$rt'd|��t)d|dz
��}|dz
}t|��||zkr |xj	||||z�z
c_	||z
}|dz
}|j
t*jzrwt|��|krf|�d|��}|dkr$||d��d��|_dS|||��d��|_dSdSdS)Nrrr~rjrrP��	r%r�r�z<BHHBzserver_status: %xrQz	salt_len:�r0r�)r��get_all_datar��findr
r�rrTr�r�r�rK�server_languager�name�server_charset�KeyErrorr�r.r/�maxrr�r�)	r�r+rcrM�
server_end�lang�stat�cap_h�salt_lens	         rr<z"Connection._get_server_informations���
���"�"�$�$���"�"�$�$�� $�Q����	�Q����Y�Y�u�a�(�(�
�"�1�Z�<�0�7�7��A�A�����N�� &�
�d�D��Q��U��O� D� D���	�Q�����Q��U��O��	�	�Q���#)�=��t�A��A��I��#G�#G��#J�� �	�Q����t�9�9��A����*0�-���a�!�a�%�i��*Q�*Q�'�D�$��x�
��F�A�$(�D� �
+�&3�D�&9�&9�&>��#�#���
+�
+�
+�&*��#�#�#�
+����"&�D���
2��)�D�0�1�1�1��$�$����3�$�$��
-��k�8�,�,�,��2�x�!�|�,�,�H�	
�R����t�9�9��H��$�$��I�I��a�!�h�,�.�/�/�I�I�
��M�A�	�Q����#�f�&8�8�	L�S��Y�Y�!�^�^����5�!�,�,�J��A�~�~�)-�a�b�b�����)A�)A��&�&�&�)-�a�
�l�);�)B�)B�7�)K�)K��&�&�&�	L�	L�^�^s�3E
�
E!� E!c��|jSr[)r�r�s r�get_server_infozConnection.get_server_info^rr!r[)F)T)C�__name__�
__module__�__qualname__�__doc__r�r�r�r-r
r�r�r�r�r��propertyr�r��__del__rAr�r�r�r�r�r�r�r�r�rr�r�rrrrrr"r%r�rNrr�rSr�rror�r=r�r�rr�r�r�r<r�r�Warningr�rq�
DatabaseError�	DataErrorr��IntegrityErrorrV�ProgrammingError�NotSupportedErrorrlr!rr.r.\s�������A�A�F
�E����G��G�
��
���
����
���������+��������������� �����Q|�|�|�|�|�|���������@ � � �,�&�&��X�&�����G�)�)�)�Q�Q�Q����������
������������J�J�J�J�/�/�/�+�+�+�
*�*�*�

&�
&�
&�
&�#�#�#�#�#�#�#�#�#�#�#�&�&�&�
����.!�!�!�J�J�J�J�X
:�
:�
:�(3�+�+�+�+�Z���2���$�$�$�$�$���)�)�)�Vo%�o%�o%�bM�M�M�^���&(�(�(�������%�%�%�?L�?L�?L�B#�#�#��k�G��I�E��'�N��%�M��
�I��+���'�N��%�M��+���-���r!r.c�\�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�ZdS)r�c��||_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
dS)z.
        :type connection: Connection
        NrF)rlrror��
warning_count�message�field_count�descriptionr�rurY)r�rls  rr�zMySQLResult.__init__ns]��%���!������!�����������������	���
�!&����r!c�@�|jr|���dSdSr[)rYrtr�s rr�zMySQLResult.__del__~s/���!�	,��)�)�+�+�+�+�+�	,�	,r!c�2�	|j���}|���r|�|��n?|���r|�|��n|�|��d|_dS#d|_wxYwr[)rlr�r�r��is_load_local_packet�_read_load_local_packet�_read_result_packet�r��first_packets  rr�zMySQLResult.read�s���
	#��?�7�7�9�9�L��(�(�*�*�
7��$�$�\�2�2�2�2��2�2�4�4�
7��,�,�\�:�:�:�:��(�(��6�6�6�"�D�O�O�O��d�D�O�"�"�"�"s�BB
�
	Bc��d|_|j���}|���r%|�|��d|_d|_dS|���r%|�|��d|_d|_dS|���|_|�	��d|_
dS)zw
        :raise OperationalError: If the connection to the MySQL server is lost.
        :raise InternalError:
        TFNl����)rYrlr�r�r�r�r��read_length_encoded_integerr��_get_descriptionsrr�s  rrkz!MySQLResult.init_unbuffered_query�s���
"&�����3�3�5�5���$�$�&�&�	6�� � ��.�.�.�%*�D�"�"�D�O�O�O�
�
.�
.�
0�
0�	6��(�(��6�6�6�%*�D�"�"�D�O�O�O�+�G�G�I�I�D���"�"�$�$�$�
"6�D���r!c��t|��}|j|_|j|_|j|_|j|_|j|_|j|_dSr[)rrror�r�r�ru)r�r��	ok_packets   rr�zMySQLResult._read_ok_packet�sR��#�L�1�1�	�&�4���"�,���&�4���&�4��� �(���!�*��
�
�
r!c��|jjstd���t|��}t	|j|j��}	|���n#|j����xYw|j���}|���stj
dd���|�|��dS)NzF**WARN**: Received LOAD_LOCAL packet but local_infile option is false.r�zCommands Out of Sync)rlr|�RuntimeErrorr�
LoadLocalFile�filenamer�r�r�rr�r�)r�r��load_packet�senderr�s     rr�z#MySQLResult._read_load_local_packet�s�����,�	��X���
�-�\�:�:���{�3�T�_�E�E��	���������	��O�(�(�*�*�*������O�0�0�2�2�	��&�&�(�(�	E��&�t�-C�D�D�D����Y�'�'�'�'�'s�A�A7c��|���sdSt|��}|j|_|j|_dS)NFT)�
is_eof_packetrr�ru)r�rc�wps   r�_check_packet_is_eofz MySQLResult._check_packet_is_eof�sC���#�#�%�%�	��5�
�f�
%�
%���-������
��tr!c��|���|_|���|���dSr[)r�r�r��_read_rowdata_packetr�s  rr�zMySQLResult._read_result_packet�s@��'�C�C�E�E������ � � ��!�!�#�#�#�#�#r!c���|jsdS|j���}|�|��rd|_d|_d|_dS|�|��}d|_|f|_|S)NFr)rYrlr�r�r��_read_row_from_packetr)r�rc�rows   r�_read_rowdata_packet_unbufferedz+MySQLResult._read_rowdata_packet_unbuffered�s����%�	��F���-�-�/�/���$�$�V�,�,�	�%*�D�"�"�D�O��D�I��F��(�(��0�0������F��	��
r!c��|jrE|j���}|�|��rd|_d|_|j�CdSdSrj)rYrlr�r�)r�rcs  rrtz$MySQLResult._finish_unbuffered_query�sh���$�	'��_�1�1�3�3�F��(�(��0�0�
'�).��&�"&���	�$�	'�	'�	'�	'�	'r!c��g}	|j���}|�|��rd|_n)|�|�|�����_t|��|_t|��|_dS)z:Read a rowdata packet for each data row in the result set.TN)	rlr�r��appendr�rKr�tupler�)r�r�rcs   rr�z MySQLResult._read_rowdata_packet�s�����	<��_�1�1�3�3�F��(�(��0�0�
�"&�����K�K��2�2�6�:�:�;�;�;�	<�!��Y�Y����$�K�K��	�	�	r!c�0�g}|jD]~\}}	|���}n#t$rYnWwxYw|�;|�|�|��}trtd|��|�||��}|�|���t|��S)NzDEBUG: DATA = )r�read_length_coded_string�
IndexErrorr
r.r/rr)r�rcrr��	converterrMs      rr�z!MySQLResult._read_row_from_packet�s�����#'�?�	�	��H�i�
��6�6�8�8�����
�
�
����
�������'��;�;�x�0�0�D��2��*�D�1�1�1��(�$�9�T�?�?�D��J�J�t������S�z�z�s�%�
3�3c�"�g|_g|_|jj}|jj}g}t|j��D�]}|j�t��}|j�	|��|�	|�
����|j}|r0|tj
kr|}n|tvr|jdkrd}n|}nd}nd}|jj�|��}|tjurd}t&rt)d|�d|����|j�	||f����|j���}	|	���s
Jd���t-|��|_
dS)z>Read a column descriptor packet for each column in the result.�?Nrz
DEBUG: field=z, converter=zProtocol error, expecting EOF)�fieldsrrlr;r��ranger�r�rrr��	type_coder
�JSON�
TEXT_TYPES�	charsetnrr�r\�throughr.r/r�r)
r�r;�
conn_encodingr�r+�field�
field_typer�r	�
eof_packets
          rr�zMySQLResult._get_descriptionss����������o�1����0�
����t�'�(�(�	:�	:�A��O�0�0�1F�G�G�E��K���u�%�%�%����u�0�0�2�2�3�3�3���J��
 ����0�0� -�H�H��:�-�-���"�,�,�#'���#0��� '�H�H�����0�4�4�Z�@�@�I��J�.�.�.� �	��
F��D�e�D�D��D�D�E�E�E��O�"�"�H�i�#8�9�9�9�9��_�1�1�3�3�
��'�'�)�)�J�J�+J�J�J�J� ��-�-����r!N)r�r�r�r�r�r�rkr�r�r�r�rrtr�r�r�rlr!rr�r�ms�������'�'�'� ,�,�,�#�#�#�6�6�6�2+�+�+�(�(�(�(
�
�
�$�$�$�
���$'�'�'� � � ����&).�).�).�).�).r!r�c��eZdZd�Zd�ZdS)r�c�"�||_||_dSr[)r�rl)r�r�rls   rr�zLoadLocalFile.__init__?s�� ��
�$����r!c���|jjstjdd���|j}	t	|jd��5}t
|jd��}	|�|��}|sn|�	|���.	ddd��n#1swxYwYn,#t$rtjdd|j�d	����wxYw|�	d
��dS#|�	d
��wxYw)z3Send data packets from the local file to the serverrr/r(i@TNi�zCan't find file 'r�r!)rlr�rrqr�r�rvrCr�rNr2r�)r��conn�	open_filerx�chunks     rr�zLoadLocalFile.send_dataCsa����$�	,��$�Q��+�+�+����	#��d�m�T�*�*�
-�i�!��+�Y����-�%�N�N�;�7�7�E� ����%�%�e�,�,�,�	-��
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-����	S�	S�	S��&�t�-Q���-Q�-Q�-Q�R�R�R�	S����
���c�"�"�"�"�"��D���c�"�"�"�"���sA�B�AB�B�B�B�B�B�C �)C�C � C7N)r�r�r�r�r�rlr!rr�r�>s2������%�%�%�#�#�#�#�#r!r�)9r3r�rbrr~rBrrr/rr7rr�	constantsrrr	r
rr�cursorsr
�
optionfiler�protocolrrrrrrrrrLr��ImportError�getpass�getuserr�r�r.�BIT�BLOB�	LONG_BLOB�MEDIUM_BLOB�STRING�	TINY_BLOB�
VAR_STRING�VARCHAR�GEOMETRYrr�rWr r,r.r�r�rlr!r�<module>r-s���

����	�	�	�	�
�
�
�
�
�
�
�
�
�
�
�
���������������3�3�3�3�3�3�3�3�E�E�E�E�E�E�E�E�E�E�E�E�E�E�����������������������������������"�!�!�!�!�!�!�!���J�J�J��K�K������
�C��K�K�K�������N�N�N�"�7�?�$�$�L�����X������L�L�L�����	���N��O���������������
�
�����$�$�$�

�
�
�(N.�N.�N.�N.�N.�N.�N.�N.�b N.�N.�N.�N.�N.�N.�N.�N.�b#�#�#�#�#�#�#�#�#�#s$�$A+�+	A7�6A7�;B�	B�B

Youez - 2016 - github.com/yon3zu
LinuXploit