
    g                        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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/m0Z0 ddl1m2Z2m3Z3m4Z4 dZ5	 ddl6Z6ddl6m7Z7 ddl8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZD dZ5n# eE$ rZF eEdeF d          eFdZF[Fww xY wddlGmHZH ddlImJZJ eHrddlKmLZLmMZM  G d de          ZNd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-raise_warning_against_deprecated_cursor_class)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CMySQLCursorBufferedNamedTupleCMySQLCursorBufferedRawCMySQLCursorDictCMySQLCursorNamedTupleCMySQLCursorPreparedCMySQLCursorPreparedDictCMySQLCursorPreparedNamedTupleCMySQLCursorPreparedRawCMySQLCursorRawTz2MySQL Connector/Python C Extension not available ())OTEL_ENABLED)with_context_propagation)end_spanrecord_exception_eventc                       e Zd ZdZdeddf fdZdndZdndZede	fd            Z
d	eddfd
ZdodeddfdZedefd            Zej        deddfd            Zedee	         fd            Zej        de	ddfd            Zedee	         fd            Zej        de	ddfd            Zedefd            Zej        deddfd            Zedefd            ZdndZdndZeZdefdZdefdZdpded e	d!e	ddfd"Zd#eddfd$Zd%edee         fd&Zedee	         fd'            Z 	 	 	 	 	 dqd(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-Z&	 	 	 	 drd)ed*ee!e"                  d+ee         d,ee#         dede$ee         ee%         f         fd.Z'dee         fd/Z(dnd0Z)dnd1Z*dnd2Z+d3eddfd4Z,	 dsd,ee#         de-fd5Z.dee%         fd6Z/d7e0dede#fd8Z1e2d9e#d:ededee3e%e-f                  fd;            Z4d9e#deddfd<Z5d9e#deddfd=Z6e2	 	 	 dtd%ed+ee         d>ed?ededee3e%e-f                  fd@            Z7e7Z8	 	 	 	 	 	 	 	 dud>ee         d+ee         dAee         dBee9e:                  dCee         dDee         dEee	         dFee	         de:fdGZ;ede	fdH            Z<ede	fdI            Z=edefdJ            Z>edefdK            Z?edefdL            Z@dMeAde3eBe0         eCe0e0f         f         fdNZDdndOZE	 	 	 	 	 	 	 	 	 	 dvdQedRed3ed#ee	         dSedTedUedVee         dWee         dXee         ddfdYZFdefdZZG eH            d[e	dee%         fd\            ZIdnd]ZJdsd^ee	         ddfd_ZKdeLfd`ZMdae	ddfdbZNdeOfdcZPdeOfddZQdeededeOfdfZRd9e#dge	dheSdedeOf
diZTdwdAeddfdjZU	 	 dxdkeeCeef                  dleeCeef                  ddfdmZV xZWS )yCMySQLConnectionz6Class initiating a MySQL Connection using Connector/C.kwargsreturnNc                    t           st          d          d| _        g | _        t          j                            t          j                            t          j                            t          j
                            ddd          | _        t          j                    dk    rLt          j                            | j                  s(t          j                            d          rdnd| _        d| _        t!                                                       |r3	  | j        d	i | dS # t&          $ r |                                   w xY 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)selfr=   	__class__s     k/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/mysql/connector/connection_cext.pyrW   zCMySQLConnection.__init__}   sK    	SQRRR  	 02 "GOOBGOO,<,EFFGG	!
 !
 ?''7>>$"233  w~~&?@@1--0   48 	&&v&&&&&   

	 	s   D- - Ec           
      $   t           j                            d          }|d         dk    rd}nd}| j                            d|d                    d t           j        dd	         D                       t          j                    d
           dS )z!Add default connection attributes r   GPLv2zGPL-2.0
Commercialzmysql-connector-python.c                 ,    g | ]}t          |          S rE   )str).0xs     r]   
<listcomp>z<CMySQLConnection._add_default_conn_attrs.<locals>.<listcomp>   s    /U/U/U1A/U/U/U       )_connector_name_connector_license_connector_version_source_hostN)	r   LICENSEsplit_conn_attrsupdaterL   VERSIONsocketgethostname)r[   license_chunksclient_licenses      r]   _add_default_conn_attrsz(CMySQLConnection._add_default_conn_attrs   s     ..s33!''&NN)N#;&4&)hh/U/UPQRSPS@T/U/U/U&V&V & 2 4 4	 	
 	
 	
 	
 	
rh   c           	      f   | 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capabilitiesrz   )
rH   get_proto_infoget_server_info	thread_idst_server_capabilities
_handshake_check_server_version_server_version_character_setset_mysql_versionr[   s    r]   _do_handshakezCMySQLConnection._do_handshake   s     3355'+|'C'C'E'E#|5577! L??AA	
 	
  $99O56 
  
 	--d.BCCCCCrh   c                 4    | j                                         S )z6Returns the server status attribute of MYSQL structure)rH   st_server_statusr   s    r]   _server_statuszCMySQLConnection._server_status   s     |,,...rh   rK   c                 L    | j         r| j                             |           dS dS )zJset local_infile_in_path

        Set allow_local_infile_in_path.
        N)rH   !set_load_data_local_infile_option)r[   rK   s     r]   set_allow_local_infile_in_pathz/CMySQLConnection.set_allow_local_infile_in_path   s7     < 	AL::4@@@@@	A 	Arh   Tvaluec                     || _         | j        r| j                            |           | j        r| j                            |           dS dS )zuToggle unicode mode

        Set whether we return string fields as unicode or not.
        Default is True.
        N)_use_unicoderH   use_unicoderU   set_unicoder[   r   s     r]   r   zCMySQLConnection.set_unicode   s\     "< 	,L$$U+++> 	.N&&u-----	. 	.rh   c                 D    |                      d          d         }|dk    S )z#Get whether autocommit is on or offzSELECT @@session.autocommitr   r   
info_queryr   s     r]   
autocommitzCMySQLConnection.autocommit   s%      =>>qAzrh   c                     	 | j                             |           || _        dS # t          $ r'}t	          |j        |j        |j                  |d}~ww xY w)zToggle autocommitmsgerrnosqlstateN)rH   r   _autocommitr)   r   r   r   r   r[   r   errs      r]   r   zCMySQLConnection.autocommit   sq    	L##E***$D" 	 	 	%G39s|  	s   !% 
A"AAc                     | j         S N)_read_timeoutr   s    r]   read_timeoutzCMySQLConnection.read_timeout   s    !!rh   timeoutc                      t          d          )Nz
            The use of read_timeout after the connection has been established is unsupported
            in the C-Extension
            r   r[   r   s     r]   r   zCMySQLConnection.read_timeout       
 
 	
rh   c                     | j         S r   )_write_timeoutr   s    r]   write_timeoutzCMySQLConnection.write_timeout   s    ""rh   c                      t          d          )Nz
            Changes in write_timeout after the connection has been established is unsupported
            in the C-Extension
            r   r   s     r]   r   zCMySQLConnection.write_timeout   r   rh   c                 8    |                      d          d         S )zGet the current databasezSELECT DATABASE()r   r   r   s    r]   databasezCMySQLConnection.database  s     233A66rh   c                     	 | j                             |           dS # t          $ r'}t          |j        |j        |j                  |d}~ww xY w)zSet the current databaser   NrH   	select_dbr)   r   r   r   r   r   s      r]   r   zCMySQLConnection.database  si    	L""5)))))" 	 	 	%G39s|  	    
A"A

Ac                 D    t          | j        t          j        z            S )z'MySQL session has started a transaction)boolr   r   STATUS_IN_TRANSr   s    r]   in_transactionzCMySQLConnection.in_transaction  s     D'**DDEEErh   c                    | j                             | j                  d         }t          j        | j        | j        || j        pd| j        | j	        | j
                  | _        |                     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         tB                    rtE          | j                   n| j         | j#        | j$        r| j$        nd| j%        r| j%        ndd}| j&        '                    d          }|+|(                    d           d)                    |          }| j&        '                    d          C| j&        '                    d          d         pd }| j&        '                    d          d         }nd }d }|d|v r|sd}| j*        s|+                    | j&        '                    d          | j&        '                    d          | j&        '                    d          |||| j&        '                    d           pd!| j&        '                    d"          pd!| j*        d#	           tX          j-        d$k    r| j.        d%k    rd|d&<   	  | j        j/        d)i | | j0        | j        _1        | j2        r| j0        | j2        _3        n4# th          $ r'}tk          |j6        |j7        |j8        '          |d }~ww xY w| 9                                 | j*        stu          | j        d(          r~tw          | j        j<                  rg| j        <                                }t{          | j&        '                    dg                     D ]'}t}          |           t          ||           "d S d S d S d S )*Nr   )bufferedrawcharset_nameconnection_timeoutr   r~   
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   get_ssl_cipherrE   )@r   get_info_charset_idrO   MySQL	_buffered_raw_connection_timeoutr   _auth_pluginrQ   rH   isset_client_flagr   CONNECT_ARGSrp   _host_user	_password
_password1
_password2
_password3	_database_port_client_flags_unix_socket	_compress_allow_local_infile_allow_local_infile_in_path_oci_config_file_oci_config_profile
isinstance_webauthn_callbackrd   r&   _openid_token_filer   r   _sslgetsortrL   _ssl_disabledrq   rJ   name_auth_plugin_classrX   _converter_str_fallbackconverter_str_fallbackrU   str_fallbackr)   r   r   r   r   r   hasattrcallabler   setr(   r'   )	r[   r   
cnx_kwargsr   ssl_ciphersuitesr   r   ciphertls_versions	            r]   _open_connectionz!CMySQLConnection._open_connection  s   *33D4DEEaH'-^	% $ 8 =A))'
 
 
 %%j&=>> 	"!D
DJ
DJ
 
 	

 
 
 
 DJ
 D.
 4,
 
 D
 $*
 D4
 "4#C
  t4!
" !$":#
( d5s;;-d5666,!%!8262DKD..!484GNT00Q3
 
 

8 y}}^44#d+++88L11L9==+,,8	011!4<   $y}}-?@@   $#$\))$ *  8! 	"immD11 $	f 5 5#y}}U33)9$0)9'+y}}]'C'C'Lu+/9==9J+K+K+Tu$($6
 
   7d??t6:SSS04J,-	 DL ..:...262NDL/~ K.2.J+" 	 	 	%G39s|  	
 	 "	B&677	B 455	B \0022F"49==#D#DEE B B+K888,V[AAAA	B 	B 	B 	B 	B 	BB Bs   &;L" "
M,"MMc                 ,   | j         rE| j                                         r,t          | j         t          j                    d                    | j        sdS 	 |                                  | j                                         nP# t          $ rC}t          rt          | j         |           t          |j        |j        |j                  |d}~ww xY w	 t          rt          | j                    dS dS # t          rt          | j                    w w xY w)z Disconnect from the MySQL serverr   Nr   )_spanis_recordingr:   sysexc_inforH   free_resultrZ   r)   r7   r   r   r   r   r9   )r[   r   s     r]   rZ   zCMySQLConnection.close  s/   : 	B$*1133 	B"4:s|~~a/@AAA| 	F	%L    " 	 	 	 8&tz3777%G39s|  	 !  %$$$$$% %| %$$$$%s*   -B C5 
C>CCC5 5Dc                 6    | j                                          S )z8Return True if the connection to MySQL Server is closed.)rH   	connectedr   s    r]   	is_closedzCMySQLConnection.is_closed  s    <))++++rh   c                 n    | j         r-|                                  | j                                         S dS )z;Reports whether the connection to MySQL Server is availableF)rH   handle_unread_resultpingr   s    r]   is_connectedzCMySQLConnection.is_connected  s7    < 	'%%'''<$$&&&urh   Fr   r   	reconnectattemptsdelayc                     |                                   	 | j                                        }|rdS n# t          $ r Y nw xY w|r|                     ||           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  rH   r  AttributeErrorr!  r   )r[   r!  r"  r#  r  s        r]   r  zCMySQLConnection.ping  s     	!!###	))++I    	 	 	D	  	INNHEN::::: !GHHHs   4 
A Ar|   c                 :    | j                             |           dS )z;Sets the default character set name for current connection.N)rH   set_character_set)r[   r|   s     r]   set_character_set_namez'CMySQLConnection.set_character_set_name  s    &&w/////rh   queryc                    d}	 | j                             |           | j         j        rZ| j                                         }| j                                         r(| j                                          t          d          | j                                          n4# t          $ r'}t          |j        |j	        |j
                  |d}~ww xY w|S )z%Send a query which only returns 1 rowrE   z'Query should not return more than 1 rowr   N)rH   r)  have_result_set	fetch_rowr  r   r)   r   r   r   r   )r[   r)  	first_rowr   s       r]   r   zCMySQLConnection.info_query  s    		Lu%%%|+ T L2244	<))++ TL,,...()RSSSL$$&&&&" 	 	 	%G39s|  	
 s   BB 
C("C

Cc                 Z    	 | j                                         S # t          $ r Y nw xY wdS )zMySQL connection IDN)rH   r   r)   r   s    r]   connection_idzCMySQLConnection.connection_id  sB    	<))+++" 	 	 	D	 ts    
((countbinarycolumnsr   	prep_stmtc                    |r|j         n| j        }| j        r|st          d          || j        }g }||dk    rt          d          d}		 |r|j        n| j        j        }
| j        s|r| j                            d            |
            }|rt          |          }| j                                        sO|sMt          | j                  D ]8\  }}|d         t          j        k    rt          j        ||                   ||<   9| j        sM| j        rFt          |          D ]6\  }}|s/| j                            | j        |         ||                   ||<   7|                    t%          |                     |	dz  }	|r|	|k    rn |
            }||sN|                     |          d         }|r|                                 d| _        n|                                  nd}n{# t,          $ rn}|r1|                                 t/          t1          |                    ||                                  t3          |j        |j        |j        	          |d}~ww xY w||fS )
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+  unread_resultrH   r   r   r%  r,  rU   r   list	enumeraterI   r   VECTORr   _vector_to_python	to_pythonappendtuplefetch_eof_columnsr  _unread_resultr)   r   rd   r   r   r   r   )r[   r0  r1  r2  r   r3  r=   r6  rowscounterr,  rowidsc__eofr   s                    r]   get_rowszCMySQLConnection.get_rows  s    6?V	11DDV 	; 	; 9:::;)C! !GHHH8	/8T	++dl>TI~ ' '   &&&)++C "3ii|'')) N# N #,DM":": N N3q6Y%555%3%Ec!f%M%MCFy XT^ X )# X X1" X%)^%=%=dmA>NPSTUPV%W%WCFE#JJ'''1 W--ikk9  ":  
484J4J94U4U5  '))+++*/D''$$&&&&" 	 	 	 8%%'''$SXX..C7%G39s|  	 Tzs   FG. .
I&8A)I!!I&c                     	 |                      d||||          \  }}|r
|d         |fS d|fS # t          $ r Y dS w xY w)z.Get the next rows returned by the MySQL serverr   )r0  r1  r2  r   r3  r   NNN)rG  
IndexError)r[   r1  r2  r   r3  r=   r@  r5  s           r]   get_rowzCMySQLConnection.get_row9  sv    	 # &  ID#  &Q~%#; 	  	  	 <<	 s   (/ / 
==c                 x    | j         r2| j                                          | j                                         S dS )zReads the next resultN)rH   consume_resultnext_resultr   s    r]   rN  zCMySQLConnection.next_resultQ  s9    < 	.L'')))<++---trh   c                 J    | j         r| j                                          dS dS )zFrees the resultN)rH   r  r   s    r]   r  zCMySQLConnection.free_resultX  s0    < 	'L$$&&&&&	' 	'rh   c                 r    | j         r/|                                  | j                                          dS dS )zCommit current transactionN)rH   r  commitr   s    r]   rQ  zCMySQLConnection.commit]  sB    < 	"%%'''L!!!!!	" 	"rh   c                 |    | j         r4| j                                          | j                                          dS dS )zRollback current transactionN)rH   rM  rollbackr   s    r]   rS  zCMySQLConnection.rollbackc  sD    < 	$L'')))L!!#####	$ 	$rh   r   c                     	 | j                             |           dS # t          $ r'}t          |j        |j        |j                  |d}~ww xY w)zChange the current databaser   Nr   )r[   r   r   s      r]   cmd_init_dbzCMySQLConnection.cmd_init_dbi  si    	L""8,,,,," 	 	 	%G39s|  	r   c                    |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        z  t          |d                   t          |d                   f	           | j	        | j        
                                d| j        dS )	z Fetch EOF and column informationNo result set      N	      )status_flagwarning_count)r5  r2  )r+  rH   r   fetch_fieldsrI   r<  intr   NOT_NULLr   st_warning_count)r[   r3  r+  fieldscols        r]   r>  z"CMySQLConnection.fetch_eof_columnsr  s#   
 *3TI%%8T 	  	2 111-6W'')))DL<U<U<W<W 	 	CM  FAKKQ[[L9#55AKKAKK
      $2!%!>!>!@!@  }
 
 	
rh   c                     | j         ri| j                                         | j                                         | j                                         | j                                         | j        dS dS )z Fetch EOF and status information)r]  field_count	insert_idaffected_rowsr}   N)rH   ra  st_field_countrf  rg  r   r   s    r]   fetch_eof_statusz!CMySQLConnection.fetch_eof_status  sl    < 	!%!>!>!@!@#|::<<!\3355!%!;!;!=!=!%!4   trh   	statementc                     | j         st          d          	 | j                             |          }| j        |_        t          |          S # t          $ r"}t          t          |                    |d}~ww xY w)zPrepares the SQL statementMySQL Connection not availableN)	rH   r   stmt_preparer	  r
  r   r)   r   rd   )r[   rj  r=   stmtr   s        r]   cmd_stmt_preparez!CMySQLConnection.cmd_stmt_prepare  s     | 	E"#CDDD	4<,,Y77D*.*FD'!$'''" 	4 	4 	4 S**3	4s   4A 
A9A44A9statement_idargsc                    	  |j         |d| j        i n/# t          $ r"}t          t	          |                    |d}~ww xY wg | _        |j        sd| _        |                                 S d| _        | 	                    |          S )zExecutes the prepared statementquery_attrsNFT)
stmt_executers  r)   r   rd   rI   r+  r?  ri  r>  )r[   rp  rq  r=   r   s        r]   cmd_stmt_executez!CMySQLConnection.cmd_stmt_execute  s    	4%L%tJ9IJJJJ" 	4 	4 	4 S**3	4 + 	+"'D((***"%%l333s    
A<Ac                     | j         rt          d          	 |                                 dS # t          $ r'}t	          |j        |j        |j                  |d}~ww xY w)zCloses the prepared statementUnread result foundr   r   N)r?  r   
stmt_closer)   r   r   r   r   r[   rp  r=   r   s       r]   cmd_stmt_closezCMySQLConnection.cmd_stmt_close  s      	7 5666	##%%%%%" 	 	 	%	sw  	s   . 
A"AAc                     | j         rt          d          	 |                                 dS # t          $ r"}t	          t          |                    |d}~ww xY w)zResets the prepared statementrw  N)r?  r   
stmt_resetr)   r   rd   rz  s       r]   cmd_stmt_resetzCMySQLConnection.cmd_stmt_reset  sp      	7 5666	4##%%%%%" 	4 	4 	4 S**3	4s   . 
AAAr   raw_as_stringc                 :   |                                   || j        }	 t          |t                    s|                    d          }| j                            ||||| j                   nt# t          $ r'}t          |j
        |j        |j                  |d }~wt          $ r8}| j        r| j        n| j         d| j         }t#          d|df          |d }~ww xY wg | _        | j        j        s|                                 S |                                 S )Nzutf-8)r   r   r  rs  rx  :i  zConnection not available.)r   values)r  r   r   bytesencoderH   r)  rs  r)   r   r   r   r   r%  r   r   r   r   rI   r+  ri  r>  )r[   r)  r   r   r  r=   r   addrs           r]   	cmd_queryzCMySQLConnection.cmd_query  sk    	!!###;)C	eU++ .W--L!+ ,      # 	 	 	%	sw    	 	 	%)%6X!!tz<X<XDJ<X<X  #D*E#F  		 |+ 	+((***%%'''s$   AA. .
C8"BC'3CCpreparedcursor_class
dictionarynamed_tupler   r   c	                 (  
 |                      |           |                                 st          d          |s|rt          j        dt
                     |/t          |t                    st          d           ||           S |p| j	        }|p| 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$          t&          t(          t*          d}		 t-          |	         j                    |	         |           S # t0          $ rC d
t3          dd                    
fdt7          d          D                       z             dw xY w)a  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 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_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
        :param named_tuple: Rows are returned as named tuple
        :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      rX  rY     )r   r   r  ri   rX     rY  rZ  r           )cursor_name)r   r   r  r  r  z*Cursor not available with given criteria: z, c                 8    g | ]}d |z  z  dk    |         S )r   r   rE   )re   rC  rq  cursor_types     r]   rg   z+CMySQLConnection.cursor.<locals>.<listcomp>l  s1    VVV+a:PTU:U:UT!W:U:U:Urh   r  )r  r   r   warningswarnWarning
issubclassr*   r   r   r   r+   r5   r.   r/   r,   r0   r-   r1   r4   r2   r3   r   __name__KeyError
ValueErrorrL   range)r[   r   r   r  r  r  r  r   r   typesrq  r  s             @@r]   cursorzCMySQLConnection.cursor  s   N 	!!(+++  "" 	F"#DEEE 	= 	M&    
 #lL99 &S   !L$'''-t~TYt1K$;;1K1K$1Kt2K #&'%-$'(.
 

	9!+.7    'E+&--- 	 	 	OD<))VVVVVeAhhVVVWWX  	s   +E AFc                 j    | j         j        st          d          | j                                         S )z,Returns number of rows of current result setrW  )rH   r+  r   num_rowsr   s    r]   r  zCMySQLConnection.num_rowso  s3     |+ 	2 111|$$&&&rh   c                 F    | j         sdS | j                                         S )zReturns number of warningsr   )rH   r]  r   s    r]   r]  zCMySQLConnection.warning_countw  s'     | 	1|))+++rh   c                 ,    | j         sdS | j         j        S )z"Check if a result set is availableF)rH   r+  r   s    r]   result_set_availablez%CMySQLConnection.result_set_available  s     | 	5|++rh   c                     | j         S )z)Check if there are unread results or rows)r  r   s    r]   r6  zCMySQLConnection.unread_result  s     ((rh   c                 4    | j                                         S )zCheck if there are more results)rH   more_resultsr   s    r]   r  zCMySQLConnection.more_results  s     |((***rh   paramsc                     g }t          |t          t          f          r( j        r fd|D             }n'  j        j        | }nt          |t                    ri } j        r|                                D ]j\  }} j                             j        	                     j        
                    |           j                            ||                                <   knx|                                D ]:\  }} j                            |          d         ||                                <   ;n(t          dt          |          j         d| d          |S )zPrepare parameters for statements

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

        Returns dict.
        c           	          g | ]R}j                             j                             j                             |          j                            SS rE   )rU   quoteescapeto_mysql	_sql_mode)re   r   r[   s     r]   rg   z6CMySQLConnection.prepare_for_mysql.<locals>.<listcomp>  si         N((-- N33E::DN    rh   r   zCould not process parameters: (z)), it must be of type list, tuple or dict)r   r7  r=  rU   rH   convert_to_mysqldictitemsr  r  r  r  r  r   typer  )r[   r  resultr   r   s   `    r]   prepare_for_mysqlz"CMySQLConnection.prepare_for_mysql  s    :<ftUm,, 	~ 
@    "(   76?%% 	F~ 	S"(,,..  JC+/>+?+?-- N33E::DN , ,F3::<<(( #),,.. S SJC+/<+H+H+O+OPQ+RF3::<<((S #:f1F : : : : :  
 rh   c                 8    | j                                          dS )zlConsume the current result

        This method consume the result by reading (consuming) all rows.
        N)rH   rM  r   s    r]   consume_resultsz CMySQLConnection.consume_results  s    
 	##%%%%%rh    usernamer   r   r   r   r   r   r   c                 p   	 | j                             ||||||||	|
	  	         n4# t          $ r'}t          |j        |j        |j                  |d}~ww xY w|@t          |t                    st          d          |dk     rt          d          || _
        || _        |                                  dS )z!Change the current logged in userr   Nzcharset must be an integerr   z2charset should be either zero or a postive integer)rH   change_userr)   r   r   r   r   r   r_  r  r   r   _post_connection)r[   r  r   r   r|   r   r   r   r   r   r   r   s               r]   cmd_change_userz CMySQLConnection.cmd_change_user  s    	L$$"!
 
 
 
 # 	 	 	%G39s|  	 gs++ ? !=>>>{{ !UVVV&D
s   "% 
A"AAc                 d    | 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
        )rH   reset_connectionr  )r[   ress     r]   cmd_reset_connectionz%CMySQLConnection.cmd_reset_connection  s6     l++-- 	$!!###
rh   optionsc                     	 |                                   | j                            |           n4# t          $ r'}t	          |j        |j        |j                  |d }~ww xY w|                                 S )Nr   )	r  rH   refreshr)   r   r   r   r   ri  )r[   r  r   s      r]   cmd_refreshzCMySQLConnection.cmd_refresh  s    	%%'''L  ))))" 	 	 	%G39s|  	
 $$&&&s   .1 
A""AA"c                 .    |                                   dS )z,Close the current connection with the serverN)rZ   r   s    r]   cmd_quitzCMySQLConnection.cmd_quit  s    

rh   shutdown_typec                 b   | j         st          d          |r&t          j        |          st	          d          |}nt          j        }	 | j                             |           n4# t          $ r'}t          |j	        |j
        |j                  |d}~ww xY 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.
        rl  zInvalid shutdown typer   N)rH   r   r   r   r   SHUTDOWN_DEFAULTshutdownr)   r   r   r   r   rZ   )r[   r  levelr   s       r]   cmd_shutdownzCMySQLConnection.cmd_shutdown  s     | 	E"#CDDD 	2(77 >$%<===!EE 1E	L!!%((((" 	 	 	%G39s|  	 	

s   A' '
B1"BBc                    |                                   	 | j                                        }t                                          |d          S # t
          t          f$ r'}t          |j        |j	        |j
                  |d}~ww xY w)z'Return statistics from the MySQL serverF)with_headerr   N)r  rH   statr   parse_statisticsr)   r   r   r   r   r   )r[   r  r   s      r]   cmd_statisticszCMySQLConnection.cmd_statistics#  s    !!###	<$$&&D ??33De3LLL#^4 	 	 	%G39s|  	s   ;A B
#"BB
	mysql_pidc                 ~    t          |t                    st          d          |                     d|            dS )zKill a MySQL processzMySQL PID must be intzKILL N)r   r_  r  r  )r[   r  s     r]   cmd_process_killz!CMySQLConnection.cmd_process_kill/  sD    )S)) 	64555*y**+++++rh   c                     t           )zSend the DEBUG commandNotImplementedErrorr   s    r]   	cmd_debugzCMySQLConnection.cmd_debug5      !!rh   c                     t           )zSend the PING commandr  r   s    r]   cmd_pingzCMySQLConnection.cmd_ping9  r  rh   
statementsc                     t           )z/Send one or more statements to the MySQL serverr  )r[   r  r=   s      r]   cmd_query_iterzCMySQLConnection.cmd_query_iter=  r  rh   param_iddatac                     t           )zSend data for a columnr  )r[   rp  r  r  r=   s        r]   cmd_stmt_send_long_dataz(CMySQLConnection.cmd_stmt_send_long_dataA  s
     "!rh   c                     |du r| j         n| j        }| j        r|                                  dS |rt	          d          dS )z'Check whether there is an unread resultTrw  N)r?  r6  can_consume_resultsr  r   )r[   r  r6  s      r]   r  z%CMySQLConnection.handle_unread_resultK  s`    /74/?/?++TEW# 	7  """"" 	7 5666	7 	7rh   user_variablessession_variablesc                    |                                  st          d          |                                 sp	 |                     | j        | j        | j        | j        | j        | j	        | j
        | j        | j        	  	         n$# t          $ r |                                  Y nw xY w|s|r|                                 }|r5|                                D ] \  }}|                    d| d|f           !|r5|                                D ] \  }}|                    d| d|f           !|                                 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.
        r  zSET @`z` = %szSET SESSION `N)r   r   r  r  r   r   r   r   r   r   r   r   r   r   r!  r  r  executerZ   )r[   r  r  curr   r   s         r]   reset_sessionzCMySQLConnection.reset_sessionS  s   (   "" 	F"#DEEE((** 	!!$$JNN$OOO),
 
 
 
 $ ! ! !     !  	. 	++--C @"0"6"6"8"8 @ @JCKK 4 4 4 4uh????  G"3"9"9";"; G GJCKK ; ; ; ;eXFFFFIIKKKKK	 	s   A
B B%$B%)r>   N)T)Fr   r   )NFNNN)FNNNr   )NFF)NNNNNNNN)
r  r  r  Nr  r  r  NNN)FrI  )Xr  
__module____qualname____doc__r   rW   rw   r   propertyr_  r   rd   r   r   r   r   setterr   r   r   r   r   r  rZ   
disconnectr  r   r  r(  r%   r#   r   r/  r   r!   r   r
   r   rG  rK  rN  r  rQ  rS  rU  r    r>  ri  r  ro  r8   r   ru  r{  r~  r  _execute_queryr   r*   r  r  r]  r  r6  r  r"   r	   r   r  r  r  r  r   r  r  r  r$   r  r  r   r  r  r  r   r  r  r  __classcell__)r\   s   @r]   r<   r<   z   s       @@       B
 
 
 
"D D D D$ / / / / X/A3 A4 A A A A
. 
. 
. 
. 
. 
. 
. D    X
       "hsm " " " X" 
C 
D 
 
 
 
 #x} # # # X# 
S 
T 
 
 
 
 7# 7 7 7 X7 _c d    _ F F F F XFjB jB jB jBX% % % %, J,4 , , , ,d    I Id Ic Ic IRV I I I I:0c 0d 0 0 0 0
 x/@    $ x}    X  $37".2P P}P P $/0	P
 d^P N+P P 
tG}h'899	:P P P Ph 37".2     $/0  d^	 
 N+    
x (+<"==	>       0Xd^    ' ' ' '
" " " "$ $ $ $C D     59!
 !
!.1!
	!
 !
 !
 !
F(+<"=    44 4 
	4 4 4 4  4$4 4 	4
 
%)>9:	;4 4 4 4*$  
	   4$4 4 
	4 4 4 4  ##&( &(&( d^&( 	&(
 &( &( 
%)>9:	;&( &( &( &(P N $("#'59%)&*&*'+^ ^4.^ d^^ 4.	^
 tL12^ TN^ d^^ sm^  }^ 
^ ^ ^ ^@ '# ' ' ' X' ,s , , , X, ,d , , , X, )t ) ) ) X) +d + + + X+).)	xUE\ 22	3) ) ) )V& & & & !%)-,0+/)  ) )  )  	) 
 #)  )  )  )  "#)  %SM)  $C=)  
)  )  )  ) Vd      !!	'3 	'84E+F 	' 	' 	' "!	'    (3- 4    0
 
 
 
 
,# ,$ , , , ,"8 " " " ""( " " " "" " " " " " ""$" " 	"
 " 
" " " "7 7T 7d 7 7 7 7 486:/ / c3h0/ $DcN3/ 
	/ / / / / / / /rh   r<   )Or  rJ   rR   rs   r  r  typingr   r   r   r   r   r   r	   r
   r   r   r  r   _decoratingr   	abstractsr   r   	constantsr   r   r   r   r   r   
conversionr   errorsr   r   r   r   r   ry   r   r  r   r    r!   r"   r#   r$   r%   utilsr&   r'   r(   rF   rO   r)   cursor_cextr*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   ImportErrorexcopentelemetry.constantsr7   !opentelemetry.context_propagationr8   opentelemetry.instrumentationr9   r:   r<   rE   rh   r]   <module>r     s  > . - 				   



                               3 3 3 3 3 3 > > > > > > > >                ' & & & & &              $ # # # # #                           444444                            KK   
+CSCCC 
 2 1 1 1 1 1 G G G G G G POOOOOOOOH H H H H. H H H H Hs   (B5 5C:C

C