
    "i                        d Z ddlmZ ddlmZ ddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlmZ ddlmZmZmZmZmZmZmZ ddlmZmZ dd	lmZ dd
lmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& ddl'm(Z(m)Z) ddl*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2  ej3        e4          5                     ej6                                ej3        e4          Z7 G d de2          Z8dS )z/Implementing communication with MySQL servers.
    )Decimal)IOBaseN   )get_auth_plugin)
ClientFlag	ServerCmd
ServerFlag	FieldTypeflag_is_setShutdownTypeNET_BUFFER_LENGTH)errorsversion)MySQLConverter)

CursorBaseMySQLCursorMySQLCursorRawMySQLCursorBufferedMySQLCursorBufferedRawMySQLCursorPreparedMySQLCursorDictMySQLCursorBufferedDictMySQLCursorNamedTupleMySQLCursorBufferedNamedTuple)MySQLUnixSocketMySQLTCPSocket)MySQLProtocol)	int1store	int4storelc_intget_platform)MySQLConnectionAbstractc                       e Zd ZdZ fdZd Zd Z	 	 dBdZdCd	Zd
 Z	d Z
dDdZd Zd Zd ZeZ	 	 dEdZdFdZd Zed             Zd Zd Zd Zd ZdGdZ	 	 dHdZd Zd ZdIdZd Zd  Zd! Z dDd"Z!d# Z"d$ Z#d% Z$d& Z%	 	 	 dJd(Z&ed)             Z'e'j(        d*             Z'd+ Z)d, Z*dCd-Z+dKd/Z,dLd0Z-ed1             Z.	 	 dMd2Z/d3 Z0d4 Z1d5 Z2d6 Z3d7 Z4d8 Z5dNd9Z6d: Z7dOd<Z8d= Z9d> Z:d? Z;d@ Z<dA Z= xZ>S )PMySQLConnectionzConnection to a MySQL Serverc                    d | _         d | _        d | _         t          t          |           j        |i | t          | _        t          j	                    | _
        d| _        d | _        d | _        d| _        d| _        d| _        d| _        d| _        d| _        d | _        d| _        d| _        i | _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _         d | _!        d| _"        d | _#        d | _$        d | _%        d| _&        g | _'        d| _(        |r1	  | j)        d	i | d S #  | *                                 d | _         xY wd S )
N-   F z	127.0.0.1i  r   Tr    )+	_protocol_socket
_handshakesuperr$   __init__r   _converter_classr   get_default_client_flags_charset_id	_sql_mode
_time_zone_autocommit_user	_password	_database_host_port_unix_socket_client_host_client_port_ssl_force_ipv6_use_unicode_get_warnings_raise_on_warnings	_buffered_unread_result_have_next_result_raw_in_transaction_prepared_statements_ssl_active_auth_plugin_krb_service_principal_pool_config_version_query_attrs_supported_columns_desc_mfa_nfactorconnectclose)selfargskwargs	__class__s      R/srv/django_bis/venv311/lib/python3.11/site-packages/mysql/connector/connection.pyr-   zMySQLConnection.__init__E   s   -ot$$-t>v>>> .'355 
 

 	  ""'#!&	$$(!  &*#$(!&+# 	&&v&&&&&

#	 	s   0D? ?Ec                    t                      }t          j                            d          }|d         dk    rd}nd}t	          t          j                              |d         t          j                    d|d	                    d	 t          j
        dd
         D                       |d         d}| j                            |           dS )z&Add the default connection attributes. r   GPLv2zGPL-2.0
Commercialarchzmysql-connector-python.c                 ,    g | ]}t          |          S r(   )str).0xs     rU   
<listcomp>z;MySQLConnection._add_default_conn_attrs.<locals>.<listcomp>   s    666AQ666       r   )_pid	_platform_source_host_client_name_client_license_client_version_osN)r!   r   LICENSEsplitr]   osgetpidsocketgethostnamejoinVERSION_conn_attrsupdate)rQ   platformlicense_chunksclient_licensedefault_conn_attrss        rU   _add_default_conn_attrsz'MySQLConnection._add_default_conn_attrs{   s    >> ..s33!''&NN)N	$$!&)".004-"xx661!5666    I&

 

 	!355555ra   c                    | j                                         }|d         dk    rt          j        |          d| _        	 | j                            |          }n8# t          $ r+}t          j        |j	        |j
        |j                  d}~ww xY w|                     |d                   | _        |d         t          j        z  sm| j        dk    rd}t          j        |          | j                            d	          rt          j        d
d          | xj        t          j         z  c_        n!| j        s| xj        t          j        z  c_        |d         t          j        z  r |                     t          j        g           |d         t          j        z  r'd| _        |                     t          j        g           |d         t          j        z  r |                     t          j        g           || _        dS )z'Get the handshake from the MySQL server      N)msgerrnosqlstateserver_version_originalcapabilitiesmysql_clear_passwordzEClear password authentication is not supported over insecure channelsverify_certz1SSL is required but the server doesn't support iti  )r}   T)r*   recvr   get_exceptionr+   r)   parse_handshake	Exceptionget_mysql_exceptionr|   r}   r~   _check_server_version_server_versionr   SSLrI   InterfaceErrorr=   getr0   _ssl_disabledPLUGIN_AUTHset_client_flagsCLIENT_QUERY_ATTRIBUTESrL   MULTI_FACTOR_AUTHENTICATION)rQ   packet	handshakeerrerr_msgs        rU   _do_handshakezMySQLConnection._do_handshake   s#   ""$$!9&v...	D66v>>II 	D 	D 	D,	69lD D D D	D
  $99/0 2  2 (:>9 
	1 $:::4+G444y}}]++ N+ -AHLN N N N:>/1# 	1*.0^$z'== 	<!!:#9":;;;^$z'II 	H*.D'!!:#E"FGGG^$z'MM 	L!!:#I"JKKK#s   A 
B'&BBNr   r&   c                 r   d| _         |t          j        z  r| j                            ||          }| j                            |           |                    d          )d                    |                    d                    }	nd}	| j        	                    |                    d          |                    d          |                    d	          |                    d
          pd|                    d          pd|	|                    d                     d| _         | j
        r|| j
        k    r| j
        }t                              d|           t                              d| j                   | j                            d          s*| j                            d          rFt          j        dk    r6|s4t#          j                    }t                              d|| j                   t                              d|           t                              d|           | j                            | j        |||||| j         | j        |	  	        }| j                            |           |                     ||           |t          j        z  s|r|                     |           dS )ae  Authenticate with the MySQL server

        Authentication happens in two parts. We first send a response to the
        handshake. The MySQL server will then send either an AuthSwitchRequest
        or an error packet.

        Raises NotSupportedError when we get the old, insecure password
        reply back. Raises any error coming from MySQL.
        F)charsetclient_flagstls_ciphersuitesN:r'   cacertkeyr   verify_identitytls_versionsTz# _do_auth(): user: %sz## _do_auth(): self._auth_plugin: %sauthentication_ociauthentication_kerberosntz4MySQL user is empty, OS user: %s will be used for %sz# _do_auth(): password: %s	r   usernamepassworddatabaser   r   ssl_enabledauth_plugin
conn_attrs)rH   r   r   r)   make_auth_sslr*   sendr   rp   switch_to_ssl
_password1_LOGGERdebugrI   
startswithrl   namegetpassgetuser	make_authr+   _auth_switch_requestCONNECT_WITH_DBcmd_init_db)
rQ   r   r   r   r   r   ssl_optionsr   r   r   s
             rU   _do_authzMySQLConnection._do_auth   s    !*.( 	$^11'?K 2 M MFLf%%%122>#&88KOO<N,O,O#P#P  #% L&&{t'<'<'2v'>'>'2u'='='2}'E'E'N'27H'I'I (-','7'2~'F'FH H H  $D? 	'x4?::H((	4 	4 	45t7H	J 	J 	J(()=>> 	-))*CDD	-W__x_((HMMF$+- - - 	.9992H===))o8,()! * # # 	&!!!!!(H555z99 	'x 	'X&&&tra   c                    d}| j         p| j        d         }t                              d|           | j                                        }|d         dk    r't          |          dk    rt          j        d          |d         dk    rZ| j	        
                    |          \  }} t          |          || j        || j                  }|                     |||          }|d         d	k    r| j	                            |          } t          |          ||| j        
          }|dk    rI|                                }|r| j                            |           | j                                        }|d         dk    r|                     |          S |d         dk    r|                     |          S |d         dk    rt          j        |          dS )zHandle second part of authentication

        Raises NotSupportedError when we get the old, insecure password
        reply back. Raises any error coming from MySQL.
        Nr   znew_auth_plugin: %srz         zAuthentication with old (insecure) passwords is not supported. For more information, lookup Password Hashing in the latest MySQL manualr   r   r   r   r   r   caching_sha2_passwordr      r{   )rI   r+   r   r   r*   r   lenr   NotSupportedErrorr)   parse_auth_switch_requestr   r5   rH   _auth_continueparse_auth_more_dataauth_responser   
_handle_ok_handle_mfar   )rQ   r   r   authnew_auth_pluginr   	auth_dataresponses           rU   r   z$MySQLConnection._auth_switch_request   s    +Mt}/M+_===""$$!9Fq 0 0*>? ? ? AY# .BB6JJ_3??33I*x!-/ / /D ((	JJF!9>>;;FCCI3??33H$:JL L LD"999--// 0L%%h///**,,!9>>??6***AY!^^##F+++AY#&v...tra   c                    | xj         dz  c_         | j         dk    r| j        }n'| j         dk    r| j        }nt          j        d          t
                              d| j                    | j                            |dd                   \  }} t          |          d| j
        || j                  }|                     |||          }|d         dk    r| j                            |          } t          |          ||| j        	          }|d
k    rI|                                }|r| j                            |           | j                                        }|d         dk    r|                     |          S |d         dk    r|                     |          S |d         dk    rt          j        |          dS )z#Handle Multi Factor Authentication.r   r   rb   z5Failed Multi Factor Authentication (invalid N factor)z# MFA N Factor #%drz   Nr   r   r   r   r{   )rN   
_password2
_password3r   r   r   r   r)   parse_auth_next_factorr   r5   rH   r   r   r   r*   r   r   r   r   r   )rQ   r   r   r   r   r   r   s          rU   r   zMySQLConnection._handle_mfa#  s   Q!!HH!##HH'G   	*D,=>>>"nCC122J
 
 ,{++Z(	
 
 
 $$T;??!9>>;;FCCI/?;//H$:JL L LD555--// 0L%%h///**,,!9>>??6***AY!^^##F+++AY#&v...tra   c                 j   |dk    r6t                               d|           |                    | j                  }n|dk    r1t                               d|           |                    |          }nU|dk    r;t                               d| j                   |                    | j                  }n|                                }t                               d|t          |                     | j                            |           | j                                        }t                               d|           |dk    rt          |          dk    r|d	         d
k    r|d         dk    r|d	d         }|	                    |          }| j                            |           | j                                        }|d	         dk    rB|d         dk    r6|
                    |d	d                   r| j                                        }n|dk    r|dk    r|d         dk    ryd	}t                               d           t                               d|d|dz                       t                               dt          |                     t                               d           d}	d}
|	s|
d	k     rt                               dd|
dz   d           t                               d|           t                               d|d|dz                       |                    ||d                   \  }}	t                               d|           | j                            |pd           | j                                        }|
dz  }
|	s|
d	k     |	st          j        d|
|          t                               d|t          |                     |                    ||d                   }t                               d |t          |                     | j                            |           | j                                        }t                               d!|           | j                                        }t                               d"|           n|dk    r|d         dk    rd	}t                               d#           t                               d$|d|dz                       t                               d%t          |                     t                               d           d}	d}
|	s|
d	k     rt                               dd|
dz   d           t                               d&|           t                               d'|d|dz                       |	                    ||d                   \  }}	|r| j                            |           |	rnA| j                                        }t                               d(|           |
dz  }
|	s|
d	k     |	s(t          j        d)                    |
|                    t                               d*|t          |                     | j                                        }t                               d+|           |S ),z!Continue with the authentication.authentication_ldap_sasl_clientz# auth_data: %sauthentication_kerberos_clientauthentication_oci_clientz!# oci configuration file path: %sz# request: %s size: %sz# server response packet: %s   r   r   =   Nv   s   GSSAPIrz   r{   z*# Continue with sasl GSSAPI authenticationz# response header: %sr   z# response size: %sz# Negotiate a service requestFr   z%s Attempt %s %sz--------------------z<< server response: %sz# response code: %sz >> response to server: %sra   zLUnable to fulfill server request after %s attempts. Last server response: %sz0 last GSSAPI response from server: %s length: %dz* >> last response to server: %s length: %dz"<< final handshake from server: %sz<< ok packet from server: %sz%# Continue with GSSAPI authenticationz# Response header: %sz# Response size: %sz<< Server response: %sz# Response code: %sz>> Response to server: %szLUnable to fulfill server request after {} attempts. Last server response: {}z(Last response from server: %s length: %dz<< Ok packet from server: %s)r   r   r   rJ   _oci_config_filer   r*   r   r   auth_continueauth_finalizeauth_continue_krbr   r   auth_accept_close_handshakeformat)rQ   r   r   r   r   r   dec_response	cresponse
rcode_sizecompletetriesstep	last_steptokens                 rU   r   zMySQLConnection._auth_continueN  s~   ;;;MM+Y777))$*EFFHH<<<MM+Y777)))44HH777MM3T5J   ))$*?@@HH))++H.#h--HHH(###""$$4f===<<<Fq  VAY#%5%5&)r// "!"":L**<88ILi(((\&&((FayCF1IOO%%fQRRj11 1!\..00F<<<Y&&6!9+;+;JMMFGGGMM16-:a<-3HIIIMM/V===MM9:::HE 51990(EAIxPPP6???3VOZ!^O5LMMM!%!7!7z{{8K!L!Lh:DAAA!!$+#...**,,
  5199  +/05v   MMBF  
 88
9LMMIMM<I  
 Li(((\&&((FMM>GGG \&&((FMM8&AAAA;;;q	S  JMMABBBMM16/:>/3JKKKMM/V===MM9:::HE 5199&%!)X   6???)6/:>/+B   #'"4"4VJKK5H"I"Ix -L%%e,,, **,,95AAA
!  5199$  +//5veV/D/D  
 MM:F   \&&((FMM8&AAAra   c                     d}| j         r&t          j        dk    rt          | j                   }n!t	          | j        | j        | j                  }|                    | j	                   |S )zGet connection based on configuration

        This method will return the appropriated connection object using
        the connection parameters.

        Returns subclass of MySQLBaseSocket.
        Nr   )unix_socket)hostport
force_ipv6)
r   rl   r   r   r   server_hostserver_portr>   set_connection_timeout_connection_timeout)rQ   prtclsconns      rU   _get_connectionzMySQLConnection._get_connection  sv      	?4"t/?@@@DD!t'7'+'7-1-=? ? ?D 	##D$<===ra   c           	         | j         dk    rDt          j        dk    r4| j        s-t	          | j                   }|                                | _        t                      | _        |                                 | _	        	 | j	        
                                 |                                  |                     | j        | j        | j        | j        | j        | j        | j                   |                     | j                   | j        t*          j        z  r,| j	        j        | j	        _        | j	        j        | j	        _        | j	                            d           n#  |                                   xY w| j        s|t=          | j	        j        d          rdtA          | j	        j        j!                  rH| j	        j        !                                }|dv r(d| d}tE          j#        |tH                     dS dS dS dS dS )zOpen the connection to the MySQL server

        This method sets up and opens the connection to the MySQL server.

        Raises on errors.
        r   r   Nr   )TLSv1zTLSv1.1zThis connection is using zZ which is now deprecated and will be removed in a future release of MySQL Connector/Python)%rI   rl   r   r5   r   get_user_from_credentialsr   r)   r   r*   open_connectionr   r   r6   r7   r0   r1   r=   rr   set_converter_classr.   r   COMPRESSrecv_compressedr   send_compressedr   r   rP   r   hasattrsockcallabler   warningswarnDeprecationWarning)rQ   clstls_versionwarn_msgs       rU   _open_connectionz MySQLConnection._open_connection  s     @@@RWPT__: =%d&788 ::<<
&++--	L((***   MM$*dn.$*<d>N)T%57 7 7 $$T%:;;;!J$77 A$(L$@!$(L$@!L//5555	JJLLL "	<)955	< *233	< ,+3355K222- - - - 
 h(:;;;;;	< 	< 	< 	< 	< 	< 32s   =CE E4c                     | j         sdS 	 | j                                          dS # t          t          j        f$ r Y dS w xY w)z.Shut down connection to MySQL Server.
        N)r*   shutdownAttributeErrorr   ErrorrQ   s    rU   r  zMySQLConnection.shutdown  s[     | 	F	L!!#####- 	 	 	DD	s   & A A c                     | j         sdS 	 |                                  n# t          t          j        f$ r Y nw xY w| j                                          d| _        dS )z Disconnect from the MySQL serverN)r*   cmd_quitr  r   r	  close_connectionr+   r
  s    rU   rP   zMySQLConnection.close  sk    | 	F	MMOOOO- 	 	 	D	%%'''s     99Tc                    |                                   	 | j                            | j                            ||p|          ||           n"# t
          $ r t          j        d          w xY w|sdS | j                                        S )a4  Send a command to the MySQL server

        This method sends a command with an optional argument.
        If packet is not None, it will be sent and the argument will be
        ignored.

        The packet_number is optional and should usually not be used.

        Some commands might not result in the MySQL server returning
        a response. If a command does not return anything, you should
        set expect_response to False. The _send_cmd method will then
        return None instead of a MySQL packet.

        Returns a MySQL packet or None.
        MySQL Connection not available.N)	handle_unread_resultr*   r   r)   make_commandr  r   OperationalErrorr   )rQ   commandargumentpacket_numberr   expect_responsecompressed_packet_numbers          rU   	_send_cmdzMySQLConnection._send_cmd%  s    " 	!!###	ML++GV5GxHH79 9 9 9  	M 	M 	M)*KLLL	M  	4|  """s   7A A-Fc                    |                                   t          |d          st          d          	 |                    t          dz
            }|r9| j                            |           |                    t          dz
            }|9n"# t          $ r t          j	        d          w xY w|r>	 | j                            d           n"# t          $ r t          j	        d          w xY w| j        
                                S )a4  Send data to the MySQL server

        This method accepts a file-like object and sends its data
        as is to the MySQL server. If the send_empty_packet is
        True, it will send an extra empty package (for example
        when using LOAD LOCAL DATA INFILE).

        Returns a MySQL packet.
        readzexpecting a file-like object   r  ra   )r  r   
ValueErrorr  r   r*   r   r  r   r  r   )rQ   	data_filesend_empty_packetbufs       rU   
_send_datazMySQLConnection._send_dataC  s8    	!!###y&)) 	=;<<<	M..!2R!788C =!!#&&&nn%6%;<<  =  	M 	M 	M)*KLLL	M  	77!!#&&&&! 7 7 7-57 7 77 |  """s   AB B-3C C-c                     t          t          j        |          | _        t          t          j        |          | _        dS )a  Handle the server flags found in MySQL packets

        This method handles the server flags send by MySQL OK and EOF
        packets. It, for example, checks whether there exists more result
        sets or whether there is an ongoing transaction.
        N)r   r	   MORE_RESULTS_EXISTSrD   STATUS_IN_TRANSrF   )rQ   flagss     rU   _handle_server_statusz%MySQLConnection._handle_server_statusc  s9     "-Z-K-2"4 "4*:+EuMMra   c                     | j         S )z'MySQL session has started a transaction)rF   r
  s    rU   in_transactionzMySQLConnection.in_transactionn  s     ##ra   c                     |d         dk    r7| j                             |          }|                     |d                    |S |d         dk    rt          j        |          t          j        d          )a  Handle a MySQL OK packet

        This method handles a MySQL OK packet. When the packet is found to
        be an Error packet, an error will be raised. If the packet is neither
        an OK or an Error packet, errors.InterfaceError will be raised.

        Returns a dict()
        rz   r   status_flagr{   zExpected OK packet)r)   parse_okr%  r   r   r   )rQ   r   ok_pkts      rU   r   zMySQLConnection._handle_oks  sv     !9>>^,,V44F&&vm'<===MAY#&v...#$8999ra   c                     |d         dk    r7| j                             |          }|                     |d                    |S |d         dk    rt          j        |          t          j        d          )a   Handle a MySQL EOF packet

        This method handles a MySQL EOF packet. When the packet is found to
        be an Error packet, an error will be raised. If the packet is neither
        and OK or an Error packet, errors.InterfaceError will be raised.

        Returns a dict()
        rz   r   r)  r{   zExpected EOF packet)r)   	parse_eofr%  r   r   r   )rQ   r   eofs      rU   _handle_eofzMySQLConnection._handle_eof  sx     !9.**622C&&s='9:::JAY#&v...#$9:::ra   c                    t           j                            |          }t           j                            |          rt	          j        d          | j        s| j        st	          j        d          | j        s| j        rt           j                            | j                  }d}	 t           j        	                    ||g          }nJ# t          $ r=}d}t	          j        |                    t          |          ||                    d}~ww xY w||k    r*d}t	          j        |                    ||                    	 t          |d          }|                     |                     |d                    	 |                                 S # t$          t&          f$ r Y S w xY w# t$          $ rf 	 | j                            d	           n"# t,          $ r t	          j        d
          w xY wt	          j        d                    |                    w xY w# 	 |                                 w # t$          t&          f$ r Y w w xY wxY w)z'Handle a LOAD DATA INFILE LOCAL requestz#Use of symbolic link is not allowedKLOAD DATA LOCAL INFILE file request rejected due to restrictions on access.NzL{} while loading file `{}` and path `{}` given in allow_local_infile_in_pathzEThe file `{}` is not found in the given allow_local_infile_in_path {}rbT)r  ra   r  zFile '{0}' could not be read)rl   pathabspathislinkr   r  _allow_local_infile_allow_local_infile_in_pathDatabaseError
commonpathr  r   r   r]   openr   r   rP   IOError	NameErrorr*   r   r  )rQ   filename	file_nameinfile_pathc_pathr   r   r  s           rU   _handle_load_data_infilez(MySQLConnection._handle_load_data_infile  s   GOOH--	7>>)$$ 	Q)*OPPP' 	+/	+&*+ + + ' 	;D,L 	;'//$*JKKKFF++[),DEE F F F<+NN3s88YDDF F FF $$;*NN9[99; ; ;	Y--I??4??9EI $3 $K $K L L!!!!Y'     	B 	B 	B7!!#&&&&! 7 7 7-57 7 77 '.55i@@B B B	B!!!!Y'   s~   *!C 
D8DD9F- FF*)F*-
H8GHG22+HH   I"H76I7II
IIc                 P   |rt          |          dk     rt          j        d          |d         dk    r|                     |          S |d         dk    r1|dd                                         }|                     |          S |d         dk    r|                     |          S |d         dk    rt          j        |          | j        	                    |          }|rt          |t                    st          j        d	          dg|z  | _        t          d|          D ]A}| j                            | j                                        | j                  | j        |<   B|                     | j                                                  }d
| _        | j        |dS )a  Handle a MySQL Result

        This method handles a MySQL result, for example, after sending the
        query command. OK and EOF packets will be handled and returned. If
        the packet is an Error packet, an errors.Error-exception will be
        raised.

        The dictionary returned of:
        - columns: column information
        - eof: the EOF-packet information

        Returns a dict()
        rz   Empty responser      r   Nr   r{   Illegal result set.T)columnsr.  )r   r   r   r   decoderA  r/  r   r)   parse_column_count
isinstanceintrM   rangeparse_columnr*   r   python_charsetunread_result)rQ   r   r=  column_countir.  s         rU   _handle_resultzMySQLConnection._handle_result  s     
	/Vq'(8999AY!^^??6***AY#abbz((**H00:::AY###F+++AY#&v... ~88@@ 	?:lC#@#@ 	?'(=>>>"W|3q,'' 	: 	:A$(N$?$?!!##T%8%: %:Dq!! t|002233!-c:::ra   c                 Z    |                      d|||          \  }}|r
|d         |fS d|fS )aT  Get the next rows returned by the MySQL server

        This method gets one row from the result set after sending, for
        example, the query command. The result is a tuple consisting of the
        row and the EOF packet.
        If no row was available in the result set, the row data will be None.

        Returns a tuple.
        r   )countbinaryrF  rawr   N)get_rows)rQ   rT  rF  rU  rowsr.  s         rU   get_rowzMySQLConnection.get_row  sI     mm!FG(+ $ - -s 	"GS>!c{ra   c                 *   
 | j         } j        st          j        d          	 |r2 j        }|dk    rd} j                             j        |||          }n' j                             j         j	        |          }n # t          j
        $ r}d _        |d}~ww xY w|\  }}	|s6|s4 j        -|r+t           d          r j        j        

 fd|D             }|	.                     d	|	v r|	d	         n|	d
                    d _        ||	fS )a  Get all rows returned by the MySQL server

        This method gets all rows returned by the MySQL server after sending,
        for example, the query command. The result is a tuple consisting of
        a list of rows and the EOF packet.

        Returns a tuple()
        NzNo result set available.utf8mb4utf8)rS  F	converterc                 2    g | ]} |j                   S r(   )rM   )r^   rowrow_to_pythonrQ   s     rU   r`   z,MySQLConnection.get_rows.<locals>.<listcomp>   s(    KKKsMM#t'9::KKKra   r)  server_status)rE   rN  r   InternalErrorr   r)   read_binary_resultr*   read_text_resultr   r	  rM   r   r\  r_  r%  )rQ   rS  rT  rF  rU  	prep_stmtr   rW  r   eof_pr_  s   `         @rU   rV  zMySQLConnection.get_rows  s    ;)C! 	C&'ABBB	 	D,i''$G~88L'5'; ; ~66t|7;7K=B 7 D D | 	 	 	!&DI	 e 	L# 	L4#5#Ad#At[)) $B N8MKKKKKdKKKD&&}',@- @-u]';';272HJ J J!&DU{s   AB B!	BB!c                 @    | j         r|                                  dS dS )zConsume results
        N)rN  rV  r
  s    rU   consume_resultszMySQLConnection.consume_results)  s*      	MMOOOOO	 	ra   c                     |                      |                     t          j        |                    d                              S )zChange the current database

        This method changes the current (default) database by sending the
        INIT_DB command. The result is a dictionary containing the OK packet
        information.

        Returns a dict()
        utf-8)r   r  r   INIT_DBencode)rQ   r   s     rU   r   zMySQLConnection.cmd_init_db/  s=     NN9,hoog.F.FGGI I 	Ira   c           
         t          |t                    s9t          |t                    r|                    d          }t          |          }| j        dk    r| j        nd}t                      }| j        s"| j        rt          j        dt                     | j
        t          j        z  rg }g }g }	dgt          | j                  dz   dz  z  }
t          | j                  D ]\  }}|d	         }d}|V|
|dz  xx         d	|dz  z  z  cc<   |                    t!          t"          j                  t!          |          z              ht          |t&                    r5| j                            |          \  }}}|	                    |           nt          |t                    rU|                    |          }|	                    t-          t          |                    |z              t"          j        }nt          |t0                    r@|	                    t-          t          |                    |z              t"          j        }nt          |t4                    r|	                    t-          t          t          |                              |                              t          |                              |          z              t"          j        }n.t          |t8                    r5|	                    t;          j        d|                     t"          j        }nt          |t@          j         t@          j!        f          r3| j        "                    |          \  }}|	                    |           nt          |t@          j#        t@          j$        f          r3| j        %                    |          \  }}|	                    |           n2tM          j'        d(                    |j)        j*                            |                    t!          |          t!          |          z              |d                             |          }|                    t-          t          |                    |z              |+                    t-          t          | j                                       |+                    t-          d	                     |	r|+                    d,                    d |
D                       t!          d	          z              t[          ||          D ]/\  }}|+                    |           |+                    |           0|	D ]}|+                    |           |+                    |           t1          |          }	 | .                    | /                    t`          j1        |                    }nB# tL          j'        $ r0}|j2        dk    rd|j3        v rd}tM          j4        |           d
}~ww xY w| j5        rtM          j6        d          |S )a  Send a query to the MySQL server

        This method send the query to the MySQL server and returns the result.

        If there was a text result, a tuple will be returned consisting of
        the number of columns and a list containing information about these
        columns.

        When the query doesn't return a text result, the OK or EOF packet
        information as dictionary will be returned. In case the result was
        an error, exception errors.Error will be raised.

        Returns a tuple()
        ri  rZ  r[  <This version of the server does not support Query Attributescategoryr         r   Nz<dz:MySQL binary protocol can not handle '{classname}' objects)	classnamera   c                 8    g | ]}t          j        d |          S )B)structpack)r^   bits     rU   r`   z-MySQLConnection.cmd_query.<locals>.<listcomp>  s$    KKKfk#s33KKKra   il  zLoading local data is disabledr1  z8Use cmd_query_iter for statements with multiple queries.)7rI  	bytearrayr]   rk  r   rL   _query_attrsr   r   Warningr0   r   r   r   	enumerateappendr   r
   NULLrJ  r)   _prepare_binary_integerr    VARCHARbytesBLOBr   DECIMALfloatru  rv  DOUBLEdatetimedate_prepare_binary_timestamp	timedeltatime_prepare_binary_timer   ProgrammingErrorr   rT   __name__extendrp   ziprQ  r  r   QUERYr}   r|   r8  rD   r   )rQ   queryrU  bufferedraw_as_stringr   r   namestypesvaluesnull_bitmappos
attr_tuplevaluer$  packed
field_typer   _typeresultr   r   s                         rU   	cmd_queryzMySQLConnection.cmd_query;  s    %++ 	%%%% .W--e$$E"&,)";";$,,* 	"t/@ 	"MN " " " " 
 BB @	)EEF##d&7"8"81"<!BCK#,T->#?#? +7 +7Z"1=+++qS1W~=+++LL9>!:!:!*5!1!1"2 3 3 3s++ A"nDDUKKVZMM&))))s++ A!LL11EMM&U"4"4u"<===!*!2JJu-- AMM&U"4"4u"<===!*JJw// AMMs3u::#4#4#$% $%  &  & ' '),U):):7)C)CDE E E "+!2JJu-- AMM&+dE":":;;;!*!1JJ(98='IJJ A~??FF )VZMM&))))(:HM'JKK A~::5AA )VZMM&)))) 1006&+o&> 17 1@ 1@A A A Yz22&u--. / / /!!}++G44VCII..56666 MM&T%6!7!788999 MM&))$$$ 	)HHKK{KKKLLaLL!" " " $'ue#4#4 ( (KE4MM%(((MM$''''# ) )EMM%((((ef	((	)O)OPPFF& 	 	 	yD  /37::8*7333	 ! 	L'JL L L s   53W) )X(8+X##X(c              #     K   t                      }t          |t                     s9t          |t                    r|                    d          }t          |          }| j        t
          j        z  rD|                    t          d                     |                    t          d                     |                    |           t          |          }| 
                    |                     t          j        |                    V  | j        rK|                                  | 
                    | j                                                  V  | j        IdS dS )at  Send one or more statements to the MySQL server

        Similar to the cmd_query method, but instead returns a generator
        object to iterate through results. It sends the statements to the
        MySQL server and through the iterator you can get the results.

        statement = 'SELECT 1; INSERT INTO t1 VALUES (); SELECT 2'
        for result in cnx.cmd_query(statement, iterate=True):
            if 'columns' in result:
                columns = result['columns']
                rows = cnx.get_rows()
            else:
                # do something useful with INSERT result

        Returns a generator.
        r[  r   r   N)rx  rI  r]   rk  r0   r   r   r  r    r  rQ  r  r   r  rD   r  r*   r   )rQ   
statementsr   r  s       rU   cmd_query_iterzMySQLConnection.cmd_query_iter  sI     " *i00 	/*c** 7'..v66
":..J
 BB 	%MM&))$$$ MM&))$$$j!!!f!!$..%"H"HIIIII $ 	;%%'''%%dl&7&7&9&9::::: $ 	; 	; 	; 	; 	;ra   c                     |                      |                     t          j        t	          |                              S )a  Send the Refresh command to the MySQL server

        This method sends the Refresh command to the MySQL server. The options
        argument should be a bitwise value using constants.RefreshOption.
        Usage example:
         RefreshOption = mysql.connector.RefreshOption
         refresh = RefreshOption.LOG | RefreshOption.THREADS
         cnx.cmd_refresh(refresh)

        The result is a dictionary with the OK packet information.

        Returns a dict()
        )r   r  r   REFRESHr   )rQ   optionss     rU   cmd_refreshzMySQLConnection.cmd_refresh  s9     NN9,i.@.@AAC C 	Cra   c                     |                                   | j                            t          j                  }| j                            |dd           |S )a  Close the current connection with the server

        This method sends the QUIT command to the MySQL server, closing the
        current connection. Since the no response can be returned to the
        client, cmd_quit() will return the packet it send.

        Returns a str()
        r   )r  r)   r  r   QUITr*   r   rQ   r   s     rU   r  zMySQLConnection.cmd_quit  sL     	!!###,,Y^<<&!Q'''ra   c                     |r+t          j        |          st          j        d          |}nt           j        }|                     |                     t          j        t          |                              S )aZ  Shut down the MySQL Server

        This method sends the SHUTDOWN command to the MySQL server and is only
        possible if the current user has SUPER privileges. The result is a
        dictionary containing the OK packet information.

        Note: Most applications and scripts do not the SUPER privilege.

        Returns a dict()
        zInvalid shutdown type)
r   get_infor   r   SHUTDOWN_DEFAULTr/  r  r   SHUTDOWNr   )rQ   shutdown_typeatypes      rU   cmd_shutdownzMySQLConnection.cmd_shutdown  s~      	2(77 E+,CDDD!EE 1Ey/A/8/?/?!A !A B B 	Bra   c                    |                                   | j                            t          j                  }| j                            |dd           | j                            | j                                                  S )zSend the statistics command to the MySQL Server

        This method sends the STATISTICS command to the MySQL server. The
        result is a dictionary with various statistical information.

        Returns a dict()
        r   )	r  r)   r  r   
STATISTICSr*   r   parse_statisticsr   r  s     rU   cmd_statisticszMySQLConnection.cmd_statistics  sl     	!!###,,Y-ABB&!Q'''~..t|/@/@/B/BCCCra   c                     |                      |                     t          j        t	          |                              S )zKill a MySQL process

        This method send the PROCESS_KILL command to the server along with
        the process ID. The result is a dictionary with the OK packet
        information.

        Returns a dict()
        )r   r  r   PROCESS_KILLr   )rQ   	mysql_pids     rU   cmd_process_killz MySQLConnection.cmd_process_kill  s9     NN919Y3G3GHHJ J 	Jra   c                 f    |                      |                     t          j                            S )aF  Send the DEBUG command

        This method sends the DEBUG command to the MySQL server, which
        requires the MySQL user to have SUPER privilege. The output will go
        to the MySQL server error log and the result of this method is a
        dictionary with EOF packet information.

        Returns a dict()
        )r/  r  r   DEBUGr
  s    rU   	cmd_debugzMySQLConnection.cmd_debug  s&     y ? ?@@@ra   c                 f    |                      |                     t          j                            S )a  Send the PING command

        This method sends the PING command to the MySQL server. It is used to
        check if the the connection is still valid. The result of this
        method is dictionary with OK packet information.

        Returns a dict()
        )r   r  r   PINGr
  s    rU   cmd_pingzMySQLConnection.cmd_ping*  s$     t~~in==>>>ra   r'   c	                 t   d| _         || _        || _        || _        || _        || _        | j        r|| j        k    r| j        }|                                  | j        rt          j	        d          | j
                            | j        ||||| j        | j        | j        | j        	  	        }	| j                            |	dd           |r|| _        |                     ||          }
	 | j        t*          j        z  s|r|                     |           n#   xY w|| _        |                                  |
S )zChange the current logged in user

        This method allows to change the current logged in user information.
        The result is a dictionary with OK packet information.

        Returns a dict()
        r   z.Change user is not supported with compression.r   r   )rN   r5   r6   r   r   r   r  	_compressr   r   r)   make_change_userr+   r0   rH   rI   rr   r*   r   r   r   r   r   r   r1   _post_connection)rQ   r   r   r   r   	password1	password2	password3oci_config_filer   	ok_packets              rU   cmd_change_userzMySQLConnection.cmd_change_user5  sf    
!###? 	'x4?::H!!###> 	;* ,: ; ; ;00o8$*<()' 1 ) ) 	&!Q''' 	4$3D!--hAA		&)CC + +  ***	"s   ++D Dc                 8    |                      d          d         S )zGet the current databasezSELECT DATABASE()r   )
info_queryr
  s    rU   r   zMySQLConnection.databaseh  s     233A66ra   c                 6    |                      d|z             dS )zSet the current databasezUSE %sN)r  )rQ   r  s     rU   r   zMySQLConnection.databasem  s!     	x%'(((((ra   c                 B    	 |                                   n#  Y dS xY wdS )a2  Reports whether the connection to MySQL Server is available

        This method checks whether the connection to MySQL is available.
        It is similar to ping(), but unlike the ping()-method, either True
        or False is returned and no exception is raised.

        Returns True or False.
        FT)r  r
  s    rU   is_connectedzMySQLConnection.is_connectedr  s+    	MMOOOO	55ts    c                     || _         dS )zJset local_infile_in_path

        Set allow_local_infile_in_path.
        N)r7  )rQ   r3  s     rU   set_allow_local_infile_in_pathz.MySQLConnection.set_allow_local_infile_in_path  s    
 ,0(((ra   c           
         |                                  st          j        d          |                                 so	 |                     | j        | j        | j        | j        | j	        | j
        | j        | j                   n)# t          j        $ r |                                  Y nw xY w|                                 }|rD|                                D ]/\  }}|                    d                    |          |f           0|rD|                                D ]1\  }}|                    d                    |          |f           0dS dS )a  Clears the current active session

        This method resets the session state, if the MySQL server is 5.7.3
        or later active session will be reset without re-authenticating.
        For other server versions session will be reset by re-authenticating.

        It is possible to provide a sequence of variables and their values to
        be set after clearing the session. This is possible for both user
        defined variables and session variables.
        This method takes two arguments user_variables and session_variables
        which are dictionaries.

        Raises OperationalError if not connected, InternalError if there are
        unread results and InterfaceError on errors.
        r  zSET @`{0}` = %szSET SESSION `{0}` = %sN)r  r   r  cmd_reset_connectionr  r5   r6   r7   r1   r   r   r   r   r  	reconnectcursoritemsexecuter   )rQ   user_variablessession_variablescurr   r  s         rU   reset_sessionzMySQLConnection.reset_session  s       "" 	M)*KLLL((** 	!!$$TZ%)^T5E%)_do%)_%)%:	< < < <
 * ! ! !     ! kkmm 	E,2244 E E
U-44S99E8DDDD 	L/5577 L L
U4;;C@@5(KKKK	L 	LL Ls   AB #B)(B)r   c                    d}||k    r|dz   }	 |                                   |                                  |                                 rdS nT# t          $ rG}||k    r7d                    |t          |                    }t          j        |          Y d}~nd}~ww xY w|dk    rt          j	        |           ||k    dS dS )a  Attempt to reconnect to the MySQL server

        The argument attempts should be the number of times a reconnect
        is tried. The delay argument is the number of seconds to wait between
        each retry.

        You may want to set the number of attempts higher and use delay when
        you expect the MySQL server to be down for maintenance or when you
        expect the network to be temporary unavailable.

        Raises InterfaceError on errors.
        r   r   z4Can not reconnect to MySQL after {0} attempt(s): {1}N)

disconnectrO   r  r   r   r]   r   r   r  sleep)rQ   attemptsdelaycounterr   r|   s         rU   r  zMySQLConnection.reconnect  s     !!kG	5!!!$$&& E 5 5 5h&&,,2F8SXX,F,F  /444 '&&&&5
 qyy
5!!! !!!!!!s   <A 
B=BBc                     	 |                                   dS #  |r|                     ||           Y dS t          j        d          xY w)a  Check availability of the MySQL server

        When reconnect is set to True, one or more attempts are made to try
        to reconnect to the MySQL server using the reconnect()-method.

        delay is the number of seconds to wait between each retry.

        When the connection is not available, an InterfaceError is raised. Use
        the is_connected()-method if you just want to check the connection
        without raising an error.

        Raises InterfaceError on errors.
        )r  r  z%Connection to MySQL is not available.N)r  r  r   r   )rQ   r  r  r  s       rU   pingzMySQLConnection.ping  sb    	?MMOOOOO	? ?>>>>>>+ -> ? ? ?s    A
A
c                 H    | j         r| j                             d          S dS )zMySQL connection IDserver_threadidN)r+   r   r
  s    rU   connection_idzMySQLConnection.connection_id  s*     ? 	:?&&'8999tra   c           
        	 |                                   |                                 st          j        d          |4t	          |t
                    st          j        d           ||           S ||n| j        }||n| j        }d	|du r	dz  	|du r	dz  	|du r	dz  	|du r	d	z  	|du r	d
z  	t          t          t          t          t          t          t          t           t"          d	}	  |	         |           S # t$          $ rB dt'          dd                    	fdt+          d          D                       z             w xY w)a  Instantiates and returns a cursor

        By default, MySQLCursor is returned. Depending on the options
        while connecting, a buffered and/or raw cursor is instantiated
        instead. Also depending upon the cursor options, rows can be
        returned as dictionary or named tuple.

        Dictionary and namedtuple based cursors are available with buffered
        output but not raw.

        It is possible to also give a custom cursor through the
        cursor_class parameter, but it needs to be a subclass of
        mysql.connector.cursor.CursorBase.

        Raises ProgrammingError when cursor_class is not a subclass of
        CursorBase. Raises ValueError when cursor is not available.

        Returns a cursor-object
        r  Nz6Cursor class needs be to subclass of cursor.CursorBaser   Tr   r   rz   rq  r  )	r   r   r   rb   rz   r   rq  	   r  )r  rU  
dictionarynamed_tuplepreparedz*Cursor not available with given criteria: z, c                 8    g | ]}d |z  z  dk    |         S r   r   r(   )r^   rP  rR   cursor_types     rU   r`   z*MySQLConnection.cursor.<locals>.<listcomp>&  s=     (H (H (HA+6!q&+AQ+F+F )-Q+F+F+Fra   r   )r  r  r   r  
issubclassr   r  rB   rE   r   r   r   r   r   r   r   r   r   KeyErrorr  rp   rK  )
rQ   r  rU  r  cursor_classr  r  r  rR   r  s
           @@rU   r  zMySQLConnection.cursor  s   * 	!!###  "" 	M)*KLLL#lJ77 N-LN N N L$''''388_cc$)t1K$;;1K1K$1Kt2K "%&$,#

 

	J&E+&--- 	J 	J 	JODI!YY (H (H (H (H (Hq (H (H (H I II J J J	Js   4D AEc                 0    |                      d           dS )zCommit current transactionCOMMITN)_execute_queryr
  s    rU   commitzMySQLConnection.commit)  s    H%%%%%ra   c                 f    | j         r|                                  |                     d           dS )zRollback current transactionROLLBACKN)rN  rV  r  r
  s    rU   rollbackzMySQLConnection.rollback-  s4     	MMOOOJ'''''ra   c                 X    |                                   |                     |           dS )a  Execute a query

        This method simply calls cmd_query() after checking for unread
        result. If there are still unread result, an errors.InterfaceError
        is raised. Otherwise whatever cmd_query() returns is returned.

        Returns a dict()
        N)r  r  )rQ   r  s     rU   r  zMySQLConnection._execute_query4  s.     	!!###ura   c                     |                      d          }|                    |           |                                S )z%Send a query which only returns 1 rowT)r  )r  r  fetchone)rQ   r  r  s      rU   r  zMySQLConnection.info_query@  s7    d++u   ra   c                     |d         dk    r| j                             |          S |d         dk    rt          j        |          t          j        d          )aE  Handle a MySQL Binary Protocol OK packet

        This method handles a MySQL Binary Protocol OK packet. When the
        packet is found to be an Error packet, an error will be raised. If
        the packet is neither an OK or an Error packet, errors.InterfaceError
        will be raised.

        Returns a dict()
        rz   r   r{   zExpected Binary OK packet)r)   parse_binary_prepare_okr   r   r   r  s     rU   _handle_binary_okz!MySQLConnection._handle_binary_okF  sY     !9>>>99&AAAAY#&v...#$?@@@ra   c                    |rt          |          dk     rt          j        d          |d         dk    r|                     |          S |d         dk    r|                     |          S |d         dk    rt          j        |          | j                            |          }|rt          |t                    st          j        d          dg|z  }t          d|          D ]<}| j                            | j                                        | j                  ||<   =|                     | j                                                  }|||fS )a  Handle a MySQL Result

        This method handles a MySQL result, for example, after sending the
        query command. OK and EOF packets will be handled and returned. If
        the packet is an Error packet, an errors.Error-exception will be
        raised.

        The tuple returned by this method consist of:
        - the number of columns in the result,
        - a list of tuples with information about the columns,
        - the EOF packet information as a dictionary.

        Returns tuple() or dict()
        rz   rC  r   r   r{   rE  N)r   r   r   r   r/  r   r)   rH  rI  rJ  rK  rL  r*   r   rM  )rQ   r   rO  rF  rP  r.  s         rU   _handle_binary_resultz%MySQLConnection._handle_binary_resultV  sX     	/Vq'(8999AY!^^??6***AY###F+++AY#&v... ~88@@ 	?:lC#@#@ 	?'(=>>>&<'q,'' 	: 	:A44!!##T%8: :GAJJ t|002233gs++ra   c                     | j                             ||          }d| _        |                     t          j        |d           d| _        dS )zFetch a MySQL statement Result Set

        This method will send the FETCH command to MySQL together with the
        given statement id and the number of rows to fetch.
        Fr  TN)r)   make_stmt_fetchrN  r  r   
STMT_FETCH)rQ   statement_idrW  r   s       rU   cmd_stmt_fetchzMySQLConnection.cmd_stmt_fetch{  sL     //dCC"y+VUKKK!ra   c                    |                      t          j        |          }|                     |          }g |d<   g |d<   |d         dk    rt	          d|d                   D ]R}|d                             | j                            | j        	                                | j
                             S|                     | j        	                                           |d         dk    rt	          d|d                   D ]R}|d                             | j                            | j        	                                | j
                             S|                     | j        	                                           |S )zPrepare a MySQL statement

        This method will send the PREPARE command to MySQL together with the
        given statement.

        Returns a dict()
        rF  
parameters
num_paramsr   num_columns)r  r   STMT_PREPAREr  rK  r|  r)   rL  r*   r   rM  r/  )rQ   	statementr   r  _s        rU   cmd_stmt_preparez MySQLConnection.cmd_stmt_prepare  s    	 6	BB''//y!|,!##1f\233 F F|$++N//0A0A0C0C040CE EF F F F T\..00111- 1$$1f]344 F Fy!((N//0A0A0C0C040CE EF F F F T\..00111ra   r(   c           
         t          |          }i }|rvt          |          D ]f\  }}t          ||         t                    rFd}	 d||         j        v}n# t
          $ r Y nw xY w|                     ||||                    |f||<   g| j        s"| j        rt          j
        dt                     | j        t          j        z  r>| j                            ||t#          |          ||| j        | j        | j                  }	n8| j                            ||t#          |          ||| j        | j                  }	|                     t*          j        |	          }
|                     |
          }|S )z"Execute a prepared MySQL statementTbrm  rn  )converter_str_fallback)r   )listr{  rI  r   moder  cmd_stmt_send_long_datarL   ry  r   r   rz  r0   r   r   r)   make_stmt_executetupler   _converter_str_fallbackr  r   STMT_EXECUTEr  )rQ   r  datar  r$  long_data_usedparam_idr
  rT  execute_packetr   r  s               rU   cmd_stmt_executez MySQLConnection.cmd_stmt_execute  s   *%%
 
	9(44 	9 	9!d8nf55 9!F!$DN,?!?)   00x15hA A A06yN8,* 	"t/@ 	"MN " " " " 
 BB 		E!^==dE*$5$5ud.?,. .NN
 "^==dE*$5$5u'+'C > E EN 	 6~NN++F33s   A
A#"A#c                 d    |                      t          j        t          |          d           dS )zDeallocate a prepared MySQL statement

        This method deallocates the prepared statement using the
        statement_id. Note that the MySQL server does not return
        anything.
        Fr  N)r  r   
STMT_CLOSEr   rQ   r  s     rU   cmd_stmt_closezMySQLConnection.cmd_stmt_close  s;     	y+Y|-D-D', 	 	. 	. 	. 	. 	.ra   c                 L   d}d}| j         j        }	 |                    |          }|rX ||||          }|                     t          j        |d           |t          |          z  }|                    |          }|Xn"# t          $ r t          j	        d          w xY w|S )a.  Send data for a column

        This methods send data for a column (for example BLOB) for statement
        identified by statement_id. The param_id indicate which parameter
        the data belongs too.
        The data argument should be a file-like object.

        Since MySQL does not send anything back, no error is raised. When
        the MySQL server is not reachable, an OperationalError is raised.

        cmd_stmt_send_long_data should be called before cmd_stmt_execute.

        The total bytes send is returned.

        Returns int.
        i    r   F)r   r  r  )
r)   _prepare_stmt_send_long_datar  r  r   STMT_SEND_LONG_DATAr   r  r   r  )	rQ   r  r  r  
chunk_size
total_sentprepare_packetr  r   s	            rU   r  z'MySQLConnection.cmd_stmt_send_long_data  s    " 

D		M))J''C ,'hDDy<V/4  6 6 6c#hh&
ii
++  ,  	M 	M 	M)*KLLL	M s   A/B B!c                     |                      |                     t          j        t	          |                               dS )zReset data for prepared statement sent as long data

        The result is a dictionary with OK packet information.

        Returns a dict()
        N)r   r  r   
STMT_RESETr   r  s     rU   cmd_stmt_resetzMySQLConnection.cmd_stmt_reset  sK     	y';'0'>'>@ @ 	A 	A 	A 	A 	Ara   c                     	 |                      |                     t          j                             |                                  dS # t
          j        t
          j        f$ r Y dS w xY w)zResets the session state without re-authenticating

        Reset command only works on MySQL server 5.7.3 or later.
        The result is True for a successful reset otherwise False.

        Returns bool
        TF)r   r  r   RESET_CONNECTIONr  r   r   r  r
  s    rU   r  z$MySQLConnection.cmd_reset_connection  sl    	OODNN9+EFFGGG!!###4(&*AB 	 	 	55	s   AA
 
A)(A)c                 v    | j         r|                                  dS | j        rt          j        d          dS )z'Check whether there is an unread resultzUnread result foundN)can_consume_resultsrg  rN  r   ra  r
  s    rU   r  z$MySQLConnection.handle_unread_result
  sL    # 	>  """"" 	>&'<===	> 	>ra   )NNNr   r&   NN)NN)N)Nr   NTr   )F)FNN)NFNNN)FFF)r'   r'   r'   r&   r'   r'   r'   r'   r  )Fr   r   )NNNNNN)r   )r(   r(   r   )?r  
__module____qualname____doc__r-   rx   r   r   r   r   r   r   r  r  rP   r  r  r   r%  propertyr'  r   r/  rA  rQ  rX  rV  rg  r   r  r  r  r  r  r  r  r  r  r  r   setterr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r'  r  r  __classcell__)rT   s   @rU   r$   r$   C   sn       &&4 4 4 4 4l6 6 6,'$ '$ '$R ?CJN= = = =~( ( ( (T) ) )V| | ||   &+< +< +<Z	 	 	
 
 
 JHLAB# # # #<# # # #@	N 	N 	N $ $ X$: : :"; ; ;"- - -^&; &; &;P     DH+ + + +Z  
I 
I 
Ik k k kZ&; &; &;PC C C"  B B B B(D D D
J 
J 
J
A 
A 
A	? 	? 	? BDJL(*1 1 1 1f 7 7 X7 _) ) _)  0 0 0#L #L #L #LJ" " " ":? ? ? ?.   X KO,0?J ?J ?J ?JB& & &( ( (
 
 
! ! !A A A #, #, #,J	" 	" 	" 	"  8       D. . .! ! !FA A A  > > > > > > >ra   r$   )9r.  decimalr   ior   r  r   loggingrl   rn   ru  r  r   authenticationr   	constantsr   r   r	   r
   r   r   r   r'   r   r   
conversionr   r  r   r   r   r   r   r   r   r   r   r   networkr   r   protocolr   utilsr   r   r    r!   	abstractsr"   	getLoggerr  
addHandlerNullHandlerr   r$   r(   ra   rU   <module>r?     so  :                 				     + + + + + +                 
         & & & & & &# # # # # # # # # # # # # # # # # # # # # # # #
 5 4 4 4 4 4 4 4 # # # # # # = = = = = = = = = = = = . . . . . .  (   & &':w':'<'< = = =
'
H
%
%L> L> L> L> L>- L> L> L> L> L>ra   