HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //usr/lib/python3.6/site-packages/pymysql/__pycache__/connections.cpython-36.opt-1.pyc
3

�$�eq��@sVddlmZddlmZmZmZmZmZmZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZddlmZmZddlmZmZmZmZmZddlmZdd	lmZdd
lm Z ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'ddl(m)Z)m*Z*dd
lm+Z+m,Z,yddl-Z-dZ.Wne/k
�r6dZ-dZ.YnXyddl0Z0e0j1�Z2[0Wne/e3fk
�rldZ2YnXdZ4ej5dd�Z6e�r�n.e6d)k�r�dd�e7d�D�Z8dd�Z9ndd�Z9e�r�e�r�ddl:m;Z;dd�Z<ndd�Z<ej=ej>ej?ej@ejAejBejCejDejEh	ZFdZGd+ZHdd �ZId!d"�ZJGd#d$�d$eK�ZLGd%d&�d&eK�ZMGd'd(�d(eK�ZNdS),�)�print_function�)�PY2�
range_type�	text_type�str_type�JYTHON�
IRONPYTHONN)�_auth)�charset_by_name�
charset_by_id)�CLIENT�COMMAND�CR�
FIELD_TYPE�
SERVER_STATUS)�
converters)�Cursor)�Parser)�dump_packet�MysqlPacket�FieldDescriptorPacket�OKPacketWrapper�EOFPacketWrapper�LoadLocalPacketWrapper)�byte2int�int2byte)�err�VERSION_STRINGTF���cCs(g|] }|dkrt|�n
t|d��qS)�i�)�chr)�.0�i�r&�!/usr/lib/python3.6/connections.py�
<listcomp>6sr(�cCs|jd�jt�S)N�latin1)�decode�	translate�_surrogateescape_table)�sr&r&r'�_fast_surrogateescape8sr/cCs|jdd�S)N�ascii�surrogateescape)r+)r.r&r&r'r/;s)�SocketIOcCstjt||��S)N)�io�BufferedReaderr2)�sock�moder&r&r'�	_makefileFsr7cCs
|j|�S)N)�makefile)r5r6r&r&r'r7Jsr*�cCstjd|�dd�S)Nz<Ir )�struct�pack)�nr&r&r'�
pack_int24`sr=cCs�|dkrtd|��np|dkr&t|�S|dkr>dtjd|�S|dkr^d	tjd
|�dd�S|dkrvd
tjd|�Std|df��dS)NrzFEncoding %d is less than 0 - no representation in LengthEncodedInteger�r���z<Hr9��z<Ir �@��z<QzIEncoding %x is larger than %x - no representation in LengthEncodedIntegeriill)�
ValueErrorrr:r;)r%r&r&r'�
lenenc_intesrEc @seZdZdZdZdZdZdZddddddddddddeddddddddddd_ddddddddf d	d
�Z	dd�Z
d
d�Zedd��Z
dd�ZeZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd`d%d&�Zd'd(�Zd)d*�Zd+d,�Zdad-d.�Zdbd/d0�Zdcd1d2�Zd3d4�Z d5d6�Z!ddd8d9�Z"d:d;�Z#ded<d=�Z$d>d?�Z%e&fd@dA�Z'dBdC�Z(dDdE�Z)dfdFdG�Z*dHdI�Z+dJdK�Z,dLdM�Z-dNdO�Z.dPdQ�Z/dRdS�Z0dTdU�Z1dVdW�Z2dXdY�Z3dZd[�Z4d\d]�Z5e6j7Z7e6j8Z8e6j9Z9e6j:Z:e6j;Z;e6j<Z<e6j=Z=e6j>Z>e6j?Z?e6j@Z@dS)g�
Connectiona�

    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 for Py3k.
    :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 read_default_group: Group to read from in the configuration file.
    :param compress: Not supported
    :param named_pipe: Not supported
    :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 db: Alias for database. (for compatibility to MySQLdb)
    :param passwd: Alias for password. (for compatibility to MySQLdb)
    :param binary_prefix: Add _binary prefix on bytes and bytearray. (default: False)

    See `Connection <https://www.python.org/dev/peps/pep-0249/#connection-objects>`_ in the
    specification.
    N�Fr�
r?ic!$s�|dkrtjddkrd}|dk	r.|dkr.|}|dk	r@|r@|}|sH|rPtd��t|�|_|jrj|tjO}�r�|	r�tjjd�r�d}	nd}	|	�rZ�s�d�t	���j
tjj
|	����fd	d
�}!|!d|�}|!d|�}|!d
|�}|!d|�}|!d|�}t|!d|��}|!d|�}|!d|�}|�si}t|t��rZx0d+D](}"|!d|"|j|"��}#|#�r.|#||"<�q.Wd|_|�r�t�sttd��d|_|tjO}|j|�|_|�p�d|_|�p�d|_t|j�tk	�r�td��|�p�t|_|�p�d|_t|jt��r�|jjd�|_||_ ||_!||_"d|k�od kn�s*td!��|�p2d|_#|dk	�rR|dk�rRtd"��||_$|dk	�rt|dk�rttd#��||_%|�r�||_&d|_'nt(|_&d|_'|dk	�r�||_'t)|j&�j*|_*|tj+O}|j �r�|tj,O}||_-|
|_.d|_/d|_0d$|_1||_2|
dk�rt3j4}
d%d&�|
j5�D�|_6d'd&�|
j5�D�|_7||_8||_9||_:|�pJi|_;||_<| |_=d(t>tj?��t@d)�|_A|�r�||jAd*<|�r�d|_Bn|jC�dS),NrrTz3compress and named_pipe arguments are not supported�winz	c:\my.iniz/etc/my.cnfZclientcs.|r|Sy�j�|�Stk
r(|SXdS)N)�get�	Exception)�key�arg)�cfg�read_default_groupr&r'�_config�sz$Connection.__init__.<locals>._config�user�password�host�database�socket�portzbind-addresszdefault-character-set�ca�capath�certrL�cipherzssl-Fzssl module not foundZ	localhosti�zport should be of type int�r*i�3�z+connect_timeout should be >0 and <=31536000zread_timeout should be > 0zwrite_timeout should be > 0z
Not connectedcSs"i|]\}}t|�tk	r||�qSr&)�type�int)r$�k�vr&r&r'�
<dictcomp>2sz'Connection.__init__.<locals>.<dictcomp>cSs"i|]\}}t|�tkr||�qSr&)r\r])r$r^r_r&r&r'r`3sZpymysql)Z_client_nameZ_pidZ_client_version�program_name)rWrXrYrLrZ)D�sys�version_info�NotImplementedError�bool�
_local_infiler
ZLOCAL_FILES�platform�
startswithr�read�os�path�
expanduserr]�
isinstance�dictrJ�ssl�SSL_ENABLED�SSL�_create_ssl_ctx�ctxrSrVr\rD�DEFAULT_USERrQrRr�encode�db�unix_socket�bind_address�connect_timeout�
_read_timeout�_write_timeout�charset�use_unicode�DEFAULT_CHARSETr�encodingZCAPABILITIES�CONNECT_WITH_DB�client_flag�cursorclass�_result�_affected_rows�	host_info�autocommit_moderZconversions�items�encoders�decoders�sql_mode�init_command�max_allowed_packet�_auth_plugin_map�_binary_prefix�server_public_key�str�getpidr�_connect_attrs�_sock�connect)$�selfrSrQrRrTrVrwr|r�Zread_default_fileZconvr}r�r�r�ryrorO�compressZ
named_pipe�
autocommitrvZpasswdZlocal_infiler�Z
defer_connectZauth_plugin_mapZread_timeoutZ
write_timeoutrxZ
binary_prefixrar�rPrL�valuer&)rNrOr'�__init__�s�


















zConnection.__init__cCs�t|tj�r|S|jd�}|jd�}|dko2|dk}tj||d�}|oR|jdd�|_|r`tjntj|_d|kr�|j	|d|jd�d�d	|kr�|j
|d	�|jtjO_|jtj
O_|S)
NrWrX)ZcafilerX�check_hostnameTrYrL)ZkeyfilerZ)rmroZ
SSLContextrJZcreate_default_contextr�Z	CERT_NONEZ
CERT_REQUIREDZverify_modeZload_cert_chainZset_ciphersZoptionsZOP_NO_SSLv2ZOP_NO_SSLv3)r�ZsslprWrXZhasnocarsr&r&r'rrIs

zConnection._create_ssl_ctxcCsl|jrtjd��d|_|jdkr$dStjddtj�}z(y|j|�Wnt	k
rXYnXWd|j
�XdS)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.
        zAlready closedTNz<iBr)�_closedr�Errorr�r:r;rZCOM_QUIT�_write_bytesrK�_force_close)r��	send_datar&r&r'�closeZs	


zConnection.closecCs
|jdk	S)z%Return True if the connection is openN)r�)r�r&r&r'�openpszConnection.openc	Cs2|jr"y|jj�WnYnXd|_d|_dS)z%Close connection without QUIT messageN)r�r��_rfile)r�r&r&r'r�uszConnection._force_closecCs&t|�|_|j�}||kr"|j�dS)N)rer��get_autocommit�_send_autocommit_mode)r�r�Zcurrentr&r&r'r��s
zConnection.autocommitcCst|jtj@�S)N)re�
server_statusrZSERVER_STATUS_AUTOCOMMIT)r�r&r&r'r��szConnection.get_autocommitcCs0|j�}|j�stjdd��t|�}|j|_|S)Ni�zCommand Out of Sync)�_read_packet�is_ok_packetr�OperationalErrorrr�)r��pkt�okr&r&r'�_read_ok_packet�szConnection._read_ok_packetcCs&|jtjd|j|j��|j�dS)z2Set whether or not to commit after every execute()zSET AUTOCOMMIT = %sN)�_execute_commandr�	COM_QUERY�escaper�r�)r�r&r&r'r��s
z Connection._send_autocommit_modecCs|jtjd�|j�dS)zBegin transaction.ZBEGINN)r�rr�r�)r�r&r&r'�begin�szConnection.begincCs|jtjd�|j�dS)z�
        Commit changes to stable storage.

        See `Connection.commit() <https://www.python.org/dev/peps/pep-0249/#commit>`_
        in the specification.
        ZCOMMITN)r�rr�r�)r�r&r&r'�commit�szConnection.commitcCs|jtjd�|j�dS)z�
        Roll back the current transaction.

        See `Connection.rollback() <https://www.python.org/dev/peps/pep-0249/#rollback>`_
        in the specification.
        ZROLLBACKN)r�rr�r�)r�r&r&r'�rollback�szConnection.rollbackcCs$|jtjd�t|�}|j�|jS)z%Send the "SHOW WARNINGS" SQL command.z
SHOW WARNINGS)r�rr��MySQLResultri�rows)r��resultr&r&r'�
show_warnings�szConnection.show_warningscCs|jtj|�|j�dS)zI
        Set current db.

        :param db: The name of the db.
        N)r�rZCOM_INIT_DBr�)r�rvr&r&r'�	select_db�szConnection.select_dbcCsXt|t�rd|j|�dSt|ttf�rF|j|�}|jrBd|}|Stj||j	|d�S)z}Escape whatever value you pass to it.

        Non-standard, for internal use; do not use this in your applications.
        �'Z_binary)�mapping)
rmr�
escape_string�bytes�	bytearray�_quote_bytesr�rZescape_itemr|)r��objr��retr&r&r'r��s

zConnection.escapecCs|j||j�S)zjAlias for escape()

        Non-standard, for internal use; do not use this in your applications.
        )r�r�)r�r�r&r&r'�literal�szConnection.literalcCs"|jtj@r|jdd�Stj|�S)Nr�z'')r�r�"SERVER_STATUS_NO_BACKSLASH_ESCAPES�replacerr�)r�r.r&r&r'r��szConnection.escape_stringcCs,|jtj@r"dt|jdd��fStj|�S)Nz'%s'�'s'')r�rr�r/r�rZescape_bytes)r�r.r&r&r'r��szConnection._quote_bytescCs|r||�S|j|�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��cursorr&r&r'r��szConnection.cursorcCsVt|t�r4tptr4tr&|j|j�}n|j|jd�}|jtj	|�|j
|d�|_|jS)Nr1)�
unbuffered)rmrrr	rrurr�rr��_read_query_resultr�)r��sqlr�r&r&r'�query�szConnection.querycCs|j|d�|_|jS)N)r�)r�r�)r�r�r&r&r'�next_result�szConnection.next_resultcCs|jS)N)r�)r�r&r&r'�
affected_rowsszConnection.affected_rowscCs"tjd|�}|jtj|�|j�S)Nz<I)r:r;r�rZCOM_PROCESS_KILLr�)r��	thread_idrMr&r&r'�killszConnection.killTcCst|jdkr&|r|j�d}n
tjd��y|jtjd�|j�Wn.tk
rn|rh|j�|j	d�n�YnXdS)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.
        NFzAlready closedrG)
r�r�rr�r�rZCOM_PINGr�rK�ping)r�Z	reconnectr&r&r'r�s

zConnection.pingcCs:t|�j}|jtjd|j|��|j�||_||_dS)NzSET NAMES %s)rrr�rr�r�r�r|)r�r|rr&r&r'�set_charsets

zConnection.set_charsetcCs\d|_�y�|dk�r"|jr\tjtjtj�}|j|j�|j|j�d|_d|_	t
rZtd�n�i}|jdk	rx|jdf|d<x\y tj
|j|jf|jf|�}PWqzttfk
r�}z|jtjkr�wz�WYdd}~XqzXqzWd|j|jf|_t
r�td�|jtjtjd	�|jtjtjd	�|jd�||_t|d
�|_d|_|j�|j�|jdk	�rn|j �}|j!d|jf�|j"dk	�r�|j �}|j!|j"�|j#�|j$�|j%dk	�r�|j&|j%�Wn�t'k
�rV}z�d|_|dk	�r�y|j#�WnYnXt(|tttj)f��rDt*j+dd
|j|f�}||_,t-j.�|_-t
�r@t|j-�|��WYdd}~XnXdS)NFzLocalhost via UNIX socketTzconnected using unix_socketrZsource_addresszsocket %s:%dzconnected using socketr�rbzSET sql_mode=%si�z(Can't connect to MySQL server on %r (%s))/r�rwrUZAF_UNIXZSOCK_STREAM�
settimeoutryr�r��_secure�DEBUG�printrxZcreate_connectionrSrV�OSError�IOError�errno�EINTRZ
setsockoptZIPPROTO_TCPZTCP_NODELAYZ
SOL_SOCKETZSO_KEEPALIVEr�r7r��_next_seq_id�_get_server_information�_request_authenticationr�r�Zexecuter�r�r�r�r��
BaseExceptionrm�errorrr�Zoriginal_exception�	traceback�
format_exc)r�r5�kwargs�e�c�excr&r&r'r�(s~






zConnection.connectcCsDtt|��t|j�|}tr&t|�|j|�|jdd|_dS)zvWrites an entire "mysql packet" in its entirety to the network
        adding its length and sequence number.
        rr)N)r=�lenrr�r�rr�)r�Zpayload�datar&r&r'�write_packetrs

zConnection.write_packetc
Cs�t�}x�|jd�}tjd|�\}}}||d>}||jkrl|j�|dkrXtjtj	d��tj
d||jf��|jdd|_|j|�}tr�t|�||7}|d	kr�q|t
krPqW|t|�|j�}	|	j�r�|jd
k	r�|jjdkr�d|j_|	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.
        �z<HBBr?rz,Lost connection to MySQL server during queryz1Packet sequence number wrong - got %d expected %drr)i���NTF)r��_read_bytesr:�unpackr�r�rr�r�CR_SERVER_LOST�
InternalErrorr�r�MAX_PACKET_LENr�rZis_error_packetr��unbuffered_activeZraise_for_error)
r�Zpacket_typeZbuffZ
packet_headerZbtrlZbtrhZ
packet_numberZ
bytes_to_readZ	recv_data�packetr&r&r'r�}s:


zConnection._read_packetcCs�|jj|j�x�y|jj|�}PWqttfk
rr}z0|jtjkrFw|j	�t
jtj
d|f��WYdd}~Xqtk
r�|j	��YqXqWt|�|kr�|j	�t
jtj
d��|S)Nz1Lost connection to MySQL server during query (%s)z,Lost connection to MySQL server during query)r�r�rzr�rir�r�r�r�r�rr�rr�r�r�)r�Z	num_bytesr�r�r&r&r'r��s(
zConnection._read_bytescCsb|jj|j�y|jj|�Wn>tk
r\}z"|j�tjtj	d|f��WYdd}~XnXdS)NzMySQL server has gone away (%r))
r�r�r{Zsendallr�r�rr�rZCR_SERVER_GONE_ERROR)r�r�r�r&r&r'r��szConnection._write_bytesc	Csjd|_|r<yt|�}|j�WqLd|_d|_�YqLXnt|�}|j�||_|jdk	rd|j|_|jS)NF)r�r��init_unbuffered_queryr��
connectionrir�r�)r�r�r�r&r&r'r��s

zConnection._read_query_resultcCs|jr|jjSdSdS)Nr)r��	insert_id)r�r&r&r'r��szConnection.insert_idcCs|jstjdd��|jdk	rT|jjr8tjd�|jj�x|jjrL|j	�q:Wd|_t
|t�rj|j|j
�}ttt|�d�}tjd||�}||d|d�}|j|�tr�t|�d|_|tkr�dS||dd�}x@ttt|��}|j|d|��||d�}|r�|tkr�Pq�WdS)z~
        :raise InterfaceError: If the connection is closed.
        :raise ValueError: If no username was specified.
        rrGNz.Previous unbuffered result was left incompleterz<iB)r�r�InterfaceErrorr�r��warnings�warn�_finish_unbuffered_query�has_nextr�rmrrur�minr�r�r:r;r�r�rr�r�)r�Zcommandr��packet_sizeZpreluder�r&r&r'r��s6





zConnection._execute_commandc
Cs�t|jjdd�d�dkr*|jtjO_|jdkr<td��t|j	�j
}t|jt�rd|jj
|j�|_tjd|jt|d�}|jr�|jtj@r�|j|�|jj|j|jd�|_t|jd	�|_d
|_||jd}d}d}|jdkr�d}tj|j |j!�}n�|jd
k�rd}tj|j |j!�}n�|jdk�r^d}|j �rNt"�r<t#d�tj$|j |j!�}nt"�r�t#d�nD|jdk�r�d}|j�r�|jtj@�r�|j d}n|j �r�d}nd}|jtj%@�r�|t&t'|��|7}n4|jtj(@�r�|tjdt'|��|7}n||d7}|j)�r<|jtj*@�r<t|j)t��r.|j)j
|j�|_)||j)d7}|jtj+@�r\||�pTdd7}|jtj,@�r�d}x\|j-j.�D]N\}}|j
d�}|tjdt'|��|7}|j
d�}|tjdt'|��|7}�qzW|tjdt'|��|7}|j|�|j/�}	|	j0��rlt"�rt#d�|	j1�|	j2�}|jtj+@�rD|dk	�rD|j3||	�}	n&tj4|j |j!�d}|j|�|j/�}	nZ|	j5��r�t"�r�t#d�|jdk�r�tj6||	�}	n(|jdk�r�tj7||	�}	nt8j9d|j��t"�r�t#d�dS)N�.rr�zDid not specify a usernamez<iIB23sr[)Zserver_hostnamer�T�rGZmysql_native_passwordsmysql_native_passwordZcaching_sha2_passwordscaching_sha2_passwordzcaching_sha2: trying fast pathzcaching_sha2: empty passwordZsha256_passwordssha256_password��Bzutf-8zreceived auth switchzreceived extra dataz(Received extra packet for auth method %rzSucceed to auth):r]�server_version�splitr�r
Z
MULTI_RESULTSrQrDrr|�idrmrrurr:r;r�ro�server_capabilitiesrqr�rsZwrap_socketr�rSr7r�r��_auth_plugin_namer
�scramble_native_passwordrR�saltr�r�Zscramble_caching_sha2ZPLUGIN_AUTH_LENENC_CLIENT_DATArEr�ZSECURE_CONNECTIONrvr��PLUGIN_AUTHZ
CONNECT_ATTRSr�r�r�Zis_auth_switch_request�
read_uint8Zread_string�
_process_auth�scramble_old_passwordZis_extra_auth_data�caching_sha2_password_auth�sha256_password_authrr�)
r�Z
charset_idZ	data_initr�Zauthresp�plugin_nameZ
connect_attrsr^r_�auth_packetr&r&r'r�
s�










z"Connection._request_authenticationcCs0|j|�}|rNy
|j|�Stk
rL|dkrHtjdd|t|�f��YnX|dkrbtj||�S|dkrvtj||�S|dkr�tj	|j
|j��}�n~|dkr�tj|j
|j��}�n`|dkr�tj
|j
|j��d	}�n>|d
kr�|j
d	}�n(|dk�r|}�x|j�}|d@dk}|d
@d
k}|j�}	|	dk�r@|j|j
d	�n�|�r�d}
y|j||	�}
|j|
d	�WnVtk
�r�tjdd||f��Yn.tk
�r�tjdd|||
|	f��YnXntjdd||f��|j�}|j�|j��s�|�r�P�q�W|Stjdd|��|j|�|j�}|j�|S)NsdialogizGAuthentication plugin '%s' not loaded: - %r missing authenticate methodscaching_sha2_passwordssha256_passwordsmysql_native_passwordsclient_ed25519smysql_old_passwordr�smysql_clear_passwordr!rrs
Password: z3no response - TypeError within plugin.prompt methodzAAuthentication plugin '%s' not loaded: - %r missing prompt methodi
zTAuthentication plugin '%s' %r didn't respond with string. Returned '%r' to prompt %rz.Authentication plugin '%s' (%r) not configuredz)Authentication plugin '%s' not configured)�_get_auth_plugin_handlerZauthenticate�AttributeErrorrr�r\r
rrrrRZread_allZed25519_passwordrrr��prompt�	TypeErrorr�Zcheck_errorr�)r�r	r
�handlerr�r��flagZechoZlastr
Zrespr&r&r'rrsf




zConnection._process_authcCsr|jj|�}|r.t|t�r.|jj|jd��}|rjy||�}Wqntk
rftjdd||f��YqnXnd}|S)Nr0izXAuthentication plugin '%s' not loaded: - %r cannot be constructed with connection object)r�rJrmr�r+rrr�)r�r	Zplugin_classrr&r&r'r�sz#Connection._get_auth_plugin_handlercCs
|jdS)Nr)�server_thread_id)r�r&r&r'r��szConnection.thread_idcCs|jS)N)r|)r�r&r&r'�character_set_name�szConnection.character_set_namecCs|jS)N)r�)r�r&r&r'�
get_host_info�szConnection.get_host_infocCs|jS)N)�protocol_version)r�r&r&r'�get_proto_info�szConnection.get_proto_infoc	Csd}|j�}|j�}t|||d��|_|d7}|jd|�}|||�jd�|_|d}tjd|||d��|_	|d7}|||d�|_
|d7}tjd	|||d
��d|_|d
7}t|�|dk�rrtjd|||d��\}}}}|d7}||_
yt|�j|_Wntk
�r(d|_YnX||_t�rBtd
|�|j|d>O_t�rdtd|�td|d�}|d7}t|�||k�r�|j
||||�7_
||7}|d7}|jtj@�rt|�|k�r|jd|�}|dk�r�||d�jd�|_n|||�jd�|_dS)Nrrr�r*z<Ir���	z<Hrr!z<BHHBzserver_status: %xr?z	salt_len:�rHzutf-8)r�Zget_all_datarr�findr+r�r:r�rrr�r�Zserver_languager�nameZserver_charset�KeyErrorr�r�r��maxr
rr)	r�r%r�r�Z
server_endZlang�statZcap_hZsalt_lenr&r&r'r��sN 

z"Connection._get_server_informationcCs|jS)N)r�)r�r&r&r'�get_server_infoszConnection.get_server_infoi@i)N)N)F)F)T)N)F)A�__name__�
__module__�__qualname__�__doc__r�rr�r�rr�rrr��propertyr�r��__del__r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�rrr�rrrr�rr�Warningr�r�Z
DatabaseErrorZ	DataErrorr�ZIntegrityErrorr�ZProgrammingErrorZNotSupportedErrorr&r&r&r'rFts�<


	




	
J*

*h:?rFc@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)r�cCsF||_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
dS)z.
        :type connection: Connection
        NrF)r�r�r�r��
warning_count�message�field_count�descriptionr�r�r�)r�r�r&r&r'r�szMySQLResult.__init__cCs|jr|j�dS)N)r�r�)r�r&r&r'r$'szMySQLResult.__del__cCsNz@|jj�}|j�r |j|�n|j�r4|j|�n
|j|�Wdd|_XdS)N)r�r�r�r��is_load_local_packet�_read_load_local_packet�_read_result_packet)r��first_packetr&r&r'ri+s
zMySQLResult.readcCsld|_|jj�}|j�r0|j|�d|_d|_n8|j�rP|j|�d|_d|_n|j�|_|j	�d|_
dS)zw
        :raise OperationalError: If the connection to the MySQL server is lost.
        :raise InternalError:
        TFNl����)r�r�r�r�r�r*r+�read_length_encoded_integerr(�_get_descriptionsr�)r�r-r&r&r'r�8s



z!MySQLResult.init_unbuffered_querycCs<t|�}|j|_|j|_|j|_|j|_|j|_|j|_dS)N)rr�r�r�r&r'r�)r�r-�	ok_packetr&r&r'r�QszMySQLResult._read_ok_packetc	Csx|jjstd��t|�}t|j|j�}y|j�Wn|jj��YnX|jj�}|j�sjt	j
dd��|j|�dS)NzF**WARN**: Received LOAD_LOCAL packet but local_infile option is false.i�zCommands Out of Sync)r�rf�RuntimeErrorr�
LoadLocalFile�filenamer�r�r�rr�r�)r�r-Zload_packetZsenderr0r&r&r'r+Zs

z#MySQLResult._read_load_local_packetcCs(|j�sdSt|�}|j|_|j|_dS)NFT)Z
is_eof_packetrr&r�)r�r�Zwpr&r&r'�_check_packet_is_eofksz MySQLResult._check_packet_is_eofcCs|j�|_|j�|j�dS)N)r.r(r/�_read_rowdata_packet)r�r-r&r&r'r,ws
zMySQLResult._read_result_packetcCsP|js
dS|jj�}|j|�r4d|_d|_d|_dS|j|�}d|_|f|_|S)NFr)r�r�r�r4r��_read_row_from_packetr�)r�r��rowr&r&r'�_read_rowdata_packet_unbuffered|s


z+MySQLResult._read_rowdata_packet_unbufferedcCs0x*|jr*|jj�}|j|�rd|_d|_qWdS)NF)r�r�r�r4)r�r�r&r&r'r��s


z$MySQLResult._finish_unbuffered_querycCsNg}x0|jj�}|j|�r"d|_P|j|j|��qWt|�|_t|�|_dS)z:Read a rowdata packet for each data row in the result set.N)	r�r�r4�appendr6r�r��tupler�)r�r�r�r&r&r'r5�s


z MySQLResult._read_rowdata_packetcCs�g}xx|jD]n\}}y|j�}Wntk
r6PYnX|dk	rp|dk	rR|j|�}tr`td|�|dk	rp||�}|j|�qWt|�S)NzDEBUG: DATA = )rZread_length_coded_string�
IndexErrorr+r�r�r9r:)r�r�r7r�	converterr�r&r&r'r6�s

z!MySQLResult._read_row_from_packetc
Cs�g|_g|_|jj}|jj}g}x�t|j�D]�}|jjt�}|jj	|�|j	|j
��|j}|r�|tj
krp|}q�|tkr�|jdkr�d}q�|}q�d}nd}|jjj|�}|tjkr�d}tr�tdj||��|jj	||f�q,W|jj�}	t|�|_
dS)z>Read a column descriptor packet for each column in the result.�?Nr0zDEBUG: field={}, converter={})Zfieldsrr�r}rrr(r�rr9r)Z	type_coderZJSON�
TEXT_TYPESZ	charsetnrr�rJZthroughr�r��formatr:)
r�r}Z
conn_encodingr)r%ZfieldZ
field_typerr<Z
eof_packetr&r&r'r/�s6



zMySQLResult._get_descriptionsN)rr r!r�r$rir�r�r+r4r,r8r�r5r6r/r&r&r&r'r�s
	

r�c@seZdZdd�Zdd�ZdS)r2cCs||_||_dS)N)r3r�)r�r3r�r&r&r'r��szLoadLocalFile.__init__cCs�|jjstjdd��|j}zvyHt|jd��2}t|jd
�}x|j|�}|sJP|j	|�q:WWdQRXWn(t
k
r�tjddj|j���YnXWd|j	d	�XdS)z3Send data packets from the local file to the serverrrGr�r?iNi�zCan't find file '{0}'r[i@)
r�r�rr�r�r3r�r�rir�r�r�r?)r�ZconnZ	open_filer��chunkr&r&r'r��s
zLoadLocalFile.send_dataN)rr r!r�r�r&r&r&r'r2�sr2)r r!ii���)OZ
__future__rZ_compatrrrrrr	r�r3rjrUr:rbr�r�rGr
r|rrZ	constantsr
rrrrrZcursorsrZ
optionfilerZprotocolrrrrrr�utilrrrrrorp�ImportErrorZgetpassZgetuserrtrr�rcZ_py_version�ranger-r/Z	_socketior2r7ZBITZBLOBZ	LONG_BLOBZMEDIUM_BLOB�STRINGZ	TINY_BLOBZ
VAR_STRINGZVARCHARZGEOMETRYr>r~r�r=rE�objectrFr�r2r&r&r&r'�<module>s�  




(N