o
    ahȡ                  
   @   s  d 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mZm	Z	m
Z
mZmZmZmZmZmZ ddlmZ ddlmZ ddlmZmZ ddlmZmZmZmZmZ dd	lmZ dd
l m!Z!m"Z"m#Z#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/ ddl0m1Z1m2Z2m3Z3 dZ4z"ddl5Z5ddl5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z? dZ4W n e@y ZA z	e@deA deAdZA[Aww ddlBmCZC ddlDmEZE eCrddlFmGZGmHZH G dd deZIdS )z'Connection class using the C Extension.    N)
AnyBinaryIODictListNoReturnOptionalSequenceTupleTypeUnion   )version)cmd_refresh_verify_options)CMySQLPrepStmtMySQLConnectionAbstract)
ClientFlag	FieldFlag	FieldType
ServerFlagShutdownType)MySQLConverter)InterfaceErrorInternalErrorOperationalErrorProgrammingErrorget_mysql_exception)MySQLProtocol)CextEofPacketTypeCextResultTypeDescriptionTypeParamsSequenceOrDictTypeRowTypeStatsPacketType
StrOrBytes)import_objectwarn_ciphersuites_deprecatedwarn_tls_version_deprecatedF)MySQLInterfaceError)CMySQLCursorCMySQLCursorBufferedCMySQLCursorBufferedDictCMySQLCursorBufferedRawCMySQLCursorDictCMySQLCursorPreparedCMySQLCursorPreparedDictCMySQLCursorRawTz2MySQL Connector/Python C Extension not available ())OTEL_ENABLED)with_context_propagation)end_spanrecord_exception_eventc                       s  e Zd ZdZdeddf fddZdddZdd	d
Zede	fddZ
deddfddZejjdeddfddZedefddZejdeddfddZedee	 fddZejde	ddfddZedee	 fddZejde	ddfddZedefddZejdeddfddZedefd d!Zdd"d#Zdd$d%ZeZdefd&d'Zdefd(d)Zdd-ed.e	d/e	ddfd0d1Zd2eddfd3d4Zd5edee fd6d7Z edee	 fd8d9Z!		*			dd:ee	 d;ed<ee"e#  d=ee d>ee$ dede%e"e ee& f fd?d@Z'	*			dd;ed<ee"e#  d=ee d>ee$ dede%ee ee& f fdAdBZ(dee fdCdDZ)ddEdFZ*ddGdHZ+ddIdJZ,dKeddfdLdMZ-	dd>ee$ de.fdNdOZ/dee& fdPdQZ0dRe1dede$fdSdTZ2e3dUe$dVededee4e&e.f  fdWdXZ5dUe$deddfdYdZZ6dUe$deddfd[d\Z7e3		*	*dd5ed=ee d]ed^ededee4e&e.f  fd_d`Z8e8Z9							dd]ee d=ee daee dbee:e;  dcee ddee	 deee	 de;fdfdgZ<ede	fdhdiZ=ede	fdjdkZ>edefdldmZ?edefdndoZ@edefdpdqZAdreBde4eCe1 eDe1e1f f fdsdtZEddudvZF	w	w	w		w	w	w			ddxedyedKed2ee	 dzed{ed|ed}ee d~ee dee ddfddZGdefddZHeI de	dee& fddZJdddZKddee	 ddfddZLdeMfddZNde	ddfddZOdePfddZQdePfddZRdededePfddZSdUe$de	deTdedePf
ddZUddaeddfddZV		ddeeDeef  deeDeef  ddfddZW  ZXS )CMySQLConnectionz6Class initiating a MySQL Connection using Connector/C.kwargsreturnNc                    s   t stdd| _g | _tjtjtjt	j
ddd| _t dkr7tj| js7tjdr4dnd| _d| _t   |rYz| jd	i | W dS  tyX   |    w dS )
Initializationz0MySQL Connector/Python C Extension not availableNmysqlvendorpluginLinuxz/usr/lib64/mysql/pluginz/usr/lib/mysql/plugin )HAVE_CMYSQLRuntimeError_cmysql_columnsospathjoindirnameabspath_mysql_connector__file___plugin_dirplatformsystemexists	convertersuper__init__connect	Exceptionclose)selfr6   	__class__r=   W/home/air/sos/back/venv/lib/python3.10/site-packages/mysql/connector/connection_cext.pyrO   r   s6   

zCMySQLConnection.__init__c              
   C   sZ   t jd}|d dkrd}nd}| jd|ddd	 t jdd
 D t d dS )z!Add default connection attributes r   GPLv2zGPL-2.0
Commercialzmysql-connector-python.c                 S   s   g | ]}t |qS r=   )str).0xr=   r=   rV   
<listcomp>   s    z<CMySQLConnection._add_default_conn_attrs.<locals>.<listcomp>   )_connector_name_connector_license_connector_version_source_hostN)	r   LICENSEsplit_conn_attrsupdaterD   VERSIONsocketgethostname)rS   license_chunksclient_licenser=   r=   rV   _add_default_conn_attrs   s   z(CMySQLConnection._add_default_conn_attrsc              	   C   sT   | j  | j  | j  dddd| j  d| _| | jd | _| j	| j dS )z<Gather information of the MySQL server before authenticationN)protocolserver_version_originalserver_threadidcharsetserver_statusauth_plugin	auth_datacapabilitiesro   )
r@   get_proto_infoget_server_info	thread_idst_server_capabilities
_handshake_check_server_version_server_version_character_setset_mysql_versionrS   r=   r=   rV   _do_handshake   s   zCMySQLConnection._do_handshakec                 C   
   | j  S )z6Returns the server status attribute of MYSQL structure)r@   st_server_statusr   r=   r=   rV   _server_status      
zCMySQLConnection._server_statusrC   c                 C   s   | j r| j | dS dS )zJset local_infile_in_path

        Set allow_local_infile_in_path.
        N)r@   !set_load_data_local_infile_option)rS   rC   r=   r=   rV   set_allow_local_infile_in_path   s   z/CMySQLConnection.set_allow_local_infile_in_pathvaluec                 C   s2   || _ | jr| j| | jr| j| d S d S N)_use_unicoder@   use_unicoderM   set_unicoderS   r   r=   r=   rV   r      s   zCMySQLConnection.use_unicodec                 C   s   |  dd }|dkS )z#Get whether autocommit is on or offzSELECT @@session.autocommitr   r   
info_queryr   r=   r=   rV   
autocommit   s   zCMySQLConnection.autocommitc              
   C   s`   z| j | || _W dS  ty/ } zt|dr$t|j|j|jd|t	t
||d}~ww )zToggle autocommiterrnomsgsqlstateN)r@   r   _autocommitr'   hasattrr   r   r   r   r   r[   rS   r   errr=   r=   rV   r      s   
c                 C      | j S r   )_read_timeoutr   r=   r=   rV   read_timeout      zCMySQLConnection.read_timeouttimeoutc                 C      t d)Nz
            The use of read_timeout after the connection has been established is unsupported
            in the C-Extension
            r   rS   r   r=   r=   rV   r         c                 C   r   r   )_write_timeoutr   r=   r=   rV   write_timeout   r   zCMySQLConnection.write_timeoutc                 C   r   )Nz
            Changes in write_timeout after the connection has been established is unsupported
            in the C-Extension
            r   r   r=   r=   rV   r      r   c                 C   s   |  dd S )zGet the current databasezSELECT DATABASE()r   r   r   r=   r=   rV   database   s   zCMySQLConnection.databasec              
   C   Z   z	| j | W dS  ty, } zt|dr!t|j|j|jd|tt	||d}~ww )zSet the current databaser   r   N
r@   	select_dbr'   r   r   r   r   r   r   r[   r   r=   r=   rV   r      s   
c                 C   s   t | jtj@ S )z'MySQL session has started a transaction)boolr   r   STATUS_IN_TRANSr   r=   r=   rV   in_transaction
  s   zCMySQLConnection.in_transactionc           	      C   s  | j | jd }tj| j| j|| jpd| j| j	| j
d| _| tjs'i | _i d| jd| jd| jd| jd| jd| jd	| jd
| jd| jd| jd| jddd| jd| jd| jd| jd| jt| j t!rvt"| j n| j | j#| j$r| j$nd| j%r| j%ndd}| j&'d}|d ur|j(dd d)|}| j&'dd ur| j&'dd pd }| j&'dd }nd }d }|d urd|v r|sd}| j*s|+| j&'d| j&'d| j&'d|||| j&'d pd!| j&'d"pd!| j*d#	 t,j-d$kr| j.d%krd|d&< z| jj/d*i | | j0| j_1| j2r| j0| j2_3W n% t4yE } zt5|d'r:t6|j7|j8|j9d(|t:t!||d }~ww | ;  | j*swt5| jd)ryt<| jj=r{| j= }t>| j&'dg D ]}t?| t@|| qjd S d S d S d S )+Nr   )bufferedrawcharset_nameconnection_timeoutr   rs   
plugin_dirhostuserpassword	password1	password2	password3r   portclient_flagsunix_socketcompressssl_disabledT
conn_attrslocal_infileload_data_local_diroci_config_fileoci_config_profile)webauthn_callbackopenid_token_filer   r   tls_versions)reverse,tls_ciphersuitesr   zTLSv1.3TLS_AES_256_GCM_SHA384cacertkeyverify_certFverify_identity)	ssl_cassl_certssl_keyssl_cipher_suitesr   tls_cipher_suitesssl_verify_certssl_verify_identityr   ntMySQLKerberosAuthPluginuse_kerberos_gssapir   r   get_ssl_cipherr=   )Ar}   get_info_charset_idrG   MySQL	_buffered_raw_connection_timeoutr   _auth_pluginrI   r@   isset_client_flagr   CONNECT_ARGSrf   _host_user	_password
_password1
_password2
_password3	_database_portr   _unix_socket	_compress_allow_local_infile_allow_local_infile_in_path_oci_config_file_oci_config_profile
isinstance_webauthn_callbackr[   r$   _openid_token_filer   r   _sslgetsortrD   _ssl_disabledrg   rB   name_auth_plugin_classrP   _converter_str_fallbackconverter_str_fallbackrM   str_fallbackr'   r   r   r   r   r   r   r   callabler   setr&   r%   )	rS   r   
cnx_kwargsr   ssl_ciphersuitesr   r   ciphertls_versionr=   r=   rV   _open_connection  s   
	











	
z!CMySQLConnection._open_connectionc              
   C   s   | j r| j  rt| j t d  | jsd S zCz|   | j  W n+ tyN } zt	r3t| j | t
|drCt|j|j|jd|tt||d }~ww W t	rYt| j  d S d S t	rct| j  w w )Nr   r   r   )_spanis_recordingr4   sysexc_infor@   free_resultrR   r'   r1   r   r   r   r   r   r   r[   r3   )rS   r   r=   r=   rV   rR   }  s2   

zCMySQLConnection.closec                 C   s   | j   S )z8Return True if the connection to MySQL Server is closed.)r@   	connectedr   r=   r=   rV   	is_closed     zCMySQLConnection.is_closedc                 C   s   | j r|   | j  S dS )z;Reports whether the connection to MySQL Server is availableF)r@   handle_unread_resultpingr   r=   r=   rV   is_connected  s   
zCMySQLConnection.is_connectedFr   r   	reconnectattemptsdelayc                 C   sP   |    z| j }W n	 ty   Y nw |rdS |r$| j||d dS td)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.
        N)r  r  z$Connection to MySQL is not available)r  r@   r	  AttributeErrorr  r   )rS   r  r  r  r  r=   r=   rV   r	    s   zCMySQLConnection.pingrq   c                 C   s   | j | dS )z;Sets the default character set name for current connection.N)r@   set_character_set)rS   rq   r=   r=   rV   set_character_set_name  s   z'CMySQLConnection.set_character_set_namequeryc              
   C   s   d}z%| j | | j jr | j  }| j  r | j   td| j   W |S  tyJ } zt|dr?t|j	|j
|jd|tt||d}~ww )z%Send a query which only returns 1 rowr=   z'Query should not return more than 1 rowr   r   N)r@   r  have_result_set	fetch_rowr  r   r'   r   r   r   r   r   r[   )rS   r  	first_rowr   r=   r=   rV   r     s(   



zCMySQLConnection.info_queryc                 C   s"   z| j  W S  ty   Y dS w )zMySQL connection IDN)r@   rx   r'   r   r=   r=   rV   connection_id  s   zCMySQLConnection.connection_idcountbinarycolumnsr   	prep_stmtc              
   K   s  |r|j n| j}| jr|std|du r| j}g }|dur&|dkr&tdd}	z|r.|jn| jj}
| js7|r=| jd |
 }|rt	|}| j sg|sgt
| jD ]\}}|d tjkrft|| ||< qR| js| jrt
|D ]\}}|s| j| j| || ||< qq|t| |	d7 }	|r|	|krn|
 }|sB|s| |d }|r|  d| _n|   nd}W ||fS W ||fS W ||fS  ty } z"|r|  n|   t|d	rt|j|j|jd
|tt||d}~ww )z8Get all or a subset of rows returned by the MySQL serverzNo result set availableNr   z$count should be 1 or higher, or NoneTr   eofFr   r   )r  unread_resultr@   r   r   r  r  rM   r   list	enumeraterA   r   VECTORr   _vector_to_python	to_pythonappendtuplefetch_eof_columnsr  _unread_resultr'   r   r   r   r   r   r   r[   )rS   r  r  r  r   r  r6   r  rowscounterr  rowidsc__eofr   r=   r=   rV   get_rows  sv   






zCMySQLConnection.get_rowsc                 K   sJ   z| j d||||d\}}|r|d |fW S d|fW S  ty$   Y dS w )z.Get the next rows returned by the MySQL serverr   )r  r  r  r   r  r   NNN)r,  
IndexError)rS   r  r  r   r  r6   r%  r  r=   r=   rV   get_row5  s   	

zCMySQLConnection.get_rowc                 C   s   | j r| j   | j  S dS )zReads the next resultN)r@   consume_resultnext_resultr   r=   r=   rV   r1  M  s   

zCMySQLConnection.next_resultc                 C   s   | j r
| j   dS dS )zFrees the resultN)r@   r  r   r=   r=   rV   r  T  s   zCMySQLConnection.free_resultc                 C   s    | j r|   | j   dS dS )zCommit current transactionN)r@   r  commitr   r=   r=   rV   r2  Y  s   zCMySQLConnection.commitc                 C   s"   | j r| j   | j   dS dS )zRollback current transactionN)r@   r0  rollbackr   r=   r=   rV   r3  _  s   
zCMySQLConnection.rollbackr   c              
   C   r   )zChange the current databaser   r   Nr   )rS   r   r   r=   r=   rV   cmd_init_dbe  s   
zCMySQLConnection.cmd_init_dbc                 C   s   |r|j n| jj }|std|r| n| j }g | _|D ]'}| j|d t|d ddddt|d  tj@ t|d t|d f	 q| j	| j
 d| jdS )	z Fetch EOF and column informationNo result set      N	      )status_flagwarning_count)r  r  )r  r@   r   fetch_fieldsrA   r!  intr   NOT_NULLr   st_warning_count)rS   r  r  fieldscolr=   r=   rV   r#  p  s0   


z"CMySQLConnection.fetch_eof_columnsc                 C   s4   | j r| j  | j  | j  | j  | jdS dS )z Fetch EOF and status information)r;  field_count	insert_idaffected_rowsrr   N)r@   r?  st_field_countrC  rD  r   r   r=   r=   rV   fetch_eof_status  s   z!CMySQLConnection.fetch_eof_status	statementc              
   K   st   | j stdz| j |}| j|_t|W S  ty9 } zt|dr.t|j	|j
|jd|tt||d}~ww )zPrepares the SQL statementMySQL Connection not availabler   r   N)r@   r   stmt_preparer   r   r   r'   r   r   r   r   r   r   r[   )rS   rG  r6   stmtr   r=   r=   rV   cmd_stmt_prepare  s    

z!CMySQLConnection.cmd_stmt_preparestatement_idargsc              
   O   s   z|j |d| ji W n# ty. } zt|dr#t|j|j|jd|tt	||d}~ww g | _
|js<d| _|  S d| _| |S )zExecutes the prepared statementquery_attrsr   r   NFT)stmt_executerN  r'   r   r   r   r   r   r   r[   rA   r  r$  rF  r#  )rS   rL  rM  r6   r   r=   r=   rV   cmd_stmt_execute  s$   

z!CMySQLConnection.cmd_stmt_executec              
   K   d   | j rtdz|  W dS  ty1 } zt|dr&t|j|j|jd|t	t
||d}~ww )zCloses the prepared statementUnread result foundr   r   N)r$  r   
stmt_closer'   r   r   r   r   r   r   r[   rS   rL  r6   r   r=   r=   rV   cmd_stmt_close     
zCMySQLConnection.cmd_stmt_closec              
   K   rQ  )zResets the prepared statementrR  r   r   N)r$  r   
stmt_resetr'   r   r   r   r   r   r   r[   rT  r=   r=   rV   cmd_stmt_reset  rV  zCMySQLConnection.cmd_stmt_resetr   raw_as_stringc              
   K   s   |    |d u r| j}zt|ts|d}|| _d | _| jj||||| j	d W nF t
yL } zt|drAt|j|j|jd|tt||d }~w tyo } z| jrY| jn| j d| j }td|dfd|d }~ww g | _| jjs{|  S |  S )	Nzutf-8)r   r   rY  rN  r   r   :i  zConnection not available.)r   values)r  r   r   bytesencode_query_local_infile_filenamesr@   r  rN  r'   r   r   r   r   r   r   r[   r  r   r   r   r   rA   r  rF  r#  )rS   r  r   r   rY  r6   r   addrr=   r=   rV   	cmd_query  sL   	



zCMySQLConnection.cmd_querypreparedcursor_class
dictionaryr   r   c           	   
      s
  |  | |  std|s|rtjdtd |dur)t|ts%td|| S |p-| j	}|p2| j
}d|du r=dO |du rEd	O |du rMd
O |du rUdO ttttttttd}z| | W S  ty   d tdd fddtd
D  dw )ay  Instantiates and returns a cursor using C Extension

        By default, CMySQLCursor 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 a dictionary or a tuple.

        Dictionary 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_cext.CMySQLCursor.

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

        Returns instance of CMySQLCursor or subclass.

        :param buffered: Return a buffering cursor
        :param raw: Return a raw cursor
        :param prepared: Return a cursor which uses prepared statements
        :param cursor_class: Use a custom cursor class
        :param dictionary: Rows are returned as dictionary
        :return: Subclass of CMySQLCursor
        :rtype: CMySQLCursor or subclass
        MySQL Connection not available.zsThe use of read_timeout after the connection has been established is unsupported
                in the C-Extension)categoryNz=Cursor class needs be to subclass of cursor_cext.CMySQLCursorr   Tr      r6     )r   r   rg  r_   r6     rh     )r   r   rd  rb  z*Cursor not available with given criteria: z, c                    s$   g | ]}d |> @ dkr | qS )r   r   r=   )r\   r(  rM  cursor_typer=   rV   r^   t  s   $ z+CMySQLConnection.cursor.<locals>.<listcomp>)r  r
  r   warningswarnWarning
issubclassr(   r   r   r   r)   r/   r+   r,   r*   r-   r.   KeyError
ValueErrorrD   range)	rS   r   r   rb  rc  rd  r   r   typesr=   rk  rV   cursor"  s\   
%



zCMySQLConnection.cursorc                 C   s   | j jstd| j  S )z,Returns number of rows of current result setr5  )r@   r  r   num_rowsr   r=   r=   rV   rv  w  s   
zCMySQLConnection.num_rowsc                 C   s   | j sdS | j  S )zReturns number of warningsr   )r@   r;  r   r=   r=   rV   r;    s   
zCMySQLConnection.warning_countc                 C   s   | j sdS | j jS )z"Check if a result set is availableF)r@   r  r   r=   r=   rV   result_set_available  s   z%CMySQLConnection.result_set_availablec                 C   r   )z)Check if there are unread results or rows)rw  r   r=   r=   rV   r    s   zCMySQLConnection.unread_resultc                 C   r   )zCheck if there are more results)r@   more_resultsr   r=   r=   rV   rx    r   zCMySQLConnection.more_resultsparamsc                    s   g }t |ttfr jr fdd|D }|S  jj| }|S t |tr_i } jrH| D ]\}} j j	 j
| j|| < q-|S | D ]\}} j|d || < qL|S tdt|j d| d)zPrepare parameters for statements

        This method is use by cursors to prepared parameters found in the
        list (or tuple) params.

        Returns dict.
        c              	      s,   g | ]} j  j  j | jqS r=   )rM   quoteescapeto_mysql	_sql_mode)r\   r   r   r=   rV   r^     s    z6CMySQLConnection.prepare_for_mysql.<locals>.<listcomp>r   zCould not process parameters: (z)), it must be of type list, tuple or dict)r   r  r"  rM   r@   convert_to_mysqldictitemsrz  r{  r|  r}  r]  r   type__name__)rS   ry  resultr   r   r=   r   rV   prepare_for_mysql  s2   


z"CMySQLConnection.prepare_for_mysqlc                 C   s   | j   dS )zlConsume the current result

        This method consume the result by reading (consuming) all rows.
        N)r@   r0  r   r=   r=   rV   consume_results  s   z CMySQLConnection.consume_results usernamer   r   r   r   r   r   r   c                 C   s   z| j ||||||||	|
	 W n# ty3 } zt|dr(t|j|j|jd|tt	||d}~ww |durLt
|tsAtd|dk rItd|| _|| _|   dS )z!Change the current logged in userr   r   Nzcharset must be an integerr   z2charset should be either zero or a postive integer)r@   change_userr'   r   r   r   r   r   r   r[   r   r=  rr  r   r   _post_connection)rS   r  r   r   rq   r   r   r   r   r   r   r   r=   r=   rV   cmd_change_user  s<   
	
z CMySQLConnection.cmd_change_userc                 C   s   | j  }|r|   |S )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
        )r@   reset_connectionr  )rS   resr=   r=   rV   cmd_reset_connection  s   
z%CMySQLConnection.cmd_reset_connectionoptionsc              
   C   sf   z|    | j| W |  S  ty2 } zt|dr't|j|j|jd|t	t
||d }~ww )Nr   r   )r  r@   refreshr'   r   r   r   r   r   r   r[   rF  )rS   r  r   r=   r=   rV   cmd_refresh  s   
zCMySQLConnection.cmd_refreshc                 C   s   |    dS )z,Close the current connection with the serverN)rR   r   r=   r=   rV   cmd_quit  r  zCMySQLConnection.cmd_quitshutdown_typec              
   C   s   | j std|rt|std|}ntj}z| j | W n# tyC } zt|dr8t	|j
|j|jd|tt||d}~ww |   dS )zShut down the MySQL Server

        This method sends the SHUTDOWN command to the MySQL server.
        The `shutdown_type` is not used, and it's kept for backward compatibility.
        rH  zInvalid shutdown typer   r   N)r@   r   r   r   r   SHUTDOWN_DEFAULTshutdownr'   r   r   r   r   r   r[   rR   )rS   r  levelr   r=   r=   rV   cmd_shutdown  s(   

zCMySQLConnection.cmd_shutdownc              
   C   sp   |    z| j }t j|ddW S  ttfy7 } zt|dr,t|j	|j
|jd|tt||d}~ww )z'Return statistics from the MySQL serverF)with_headerr   r   N)r  r@   statr   parse_statisticsr'   r   r   r   r   r   r   r[   )rS   r  r   r=   r=   rV   cmd_statistics1  s   

zCMySQLConnection.cmd_statistics	mysql_pidc                 C   s&   t |ts	td| d|  dS )zKill a MySQL processzMySQL PID must be intzKILL N)r   r=  rr  ra  )rS   r  r=   r=   rV   cmd_process_kill?  s   
z!CMySQLConnection.cmd_process_killc                 C      t )zSend the DEBUG commandNotImplementedErrorr   r=   r=   rV   	cmd_debugE     zCMySQLConnection.cmd_debugc                 C   r  )zSend the PING commandr  r   r=   r=   rV   cmd_pingI  r  zCMySQLConnection.cmd_ping
statementsc                 K   r  )z/Send one or more statements to the MySQL serverr  )rS   r  r6   r=   r=   rV   cmd_query_iterM  r  zCMySQLConnection.cmd_query_iterparam_iddatac                 K   r  )zSend data for a columnr  )rS   rL  r  r  r6   r=   r=   rV   cmd_stmt_send_long_dataQ  s   z(CMySQLConnection.cmd_stmt_send_long_datac                 C   s6   |du r| j n| j}| jr|   dS |rtddS )z'Check whether there is an unread resultTrR  N)r$  r  can_consume_resultsr  r   )rS   rb  r  r=   r=   rV   r  [  s   z%CMySQLConnection.handle_unread_resultuser_variablessession_variablesc                 C   s   |   std|  s2z| | j| j| j| j| j| j	| j
| j| j	 W n ty1   |   Y nw |s6|rl|  }|rP| D ]\}}|d| d|f q@|rf| D ]\}}|d| d|f qV|  d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.
        re  zSET @`z` = %szSET SESSION `N)r
  r   r  r  r   r   r   r   r   r   r   r   r   r   r  ru  r  executerR   )rS   r  r  curr   r   r=   r=   rV   reset_sessionc  s8   zCMySQLConnection.reset_session)r7   N)Fr   r   )NFNNN)FNNNr   )NFF)NNNNNNN)
r  r  r  Nr  r  r  NNN)Fr-  )Yr  
__module____qualname____doc__r   rO   rm   r   propertyr=  r   r[   r   r   r   setterr   r   r   r   r   r   r   r   rR   
disconnectr  r
  r	  r  r#   r!   r   r  r   r   r   r	   r   r,  r/  r1  r  r2  r3  r4  r   r#  rF  r\  rK  r2   r   rP  rU  rX  ra  _execute_queryr
   r(   ru  rv  r;  rw  r  rx  r    r   r   r  r  r  r  r   r  r  r  r"   r  r  r   r  r  r  r   r  r  r  __classcell__r=   r=   rT   rV   r5   o   s   
!
	

n

V





#


/
	
U

+		

-



r5   )Jr  rB   rJ   ri   r  rm  typingr   r   r   r   r   r   r   r	   r
   r   r  r   _decoratingr   	abstractsr   r   	constantsr   r   r   r   r   
conversionr   errorsr   r   r   r   r   rn   r   rt  r   r   r   r    r!   r"   r#   utilsr$   r%   r&   r>   rG   r'   cursor_cextr(   r)   r*   r+   r,   r-   r.   r/   ImportErrorexcopentelemetry.constantsr1   !opentelemetry.context_propagationr2   opentelemetry.instrumentationr3   r4   r5   r=   r=   r=   rV   <module>   sF   0$	(
