
    Aahȡ                        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Z4	 ddl5Z5ddl5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z? dZ4n# e@$ rZA e@deA d          eAdZA[Aww xY wddlBmCZC ddlDmEZE eCrddlFmGZGmHZH  G 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                       e Zd ZdZdeddf fdZdldZdldZede	fd            Z
d	eddfd
Zej        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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dldZdldZeZdefdZdefdZdmd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!	 	 	 	 	 dnd'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'	 	 	 	 dod(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)dld/Z*dld0Z+dld1Z,d2eddfd3Z-	 dpd+ee$         de.fd4Z/dee&         fd5Z0d6e1dede$fd7Z2e3d8e$d9ededee4e&e.f                  fd:            Z5d8e$deddfd;Z6d8e$deddfd<Z7e3	 	 	 dqd$ed*ee         d=ed>ededee4e&e.f                  fd?            Z8e8Z9	 	 	 	 	 	 	 drd=ee         d*ee         d@ee         dAee:e;                  dBee         dCee	         dDee	         de;fdEZ<ede	fdF            Z=ede	fdG            Z>edefdH            Z?edefdI            Z@edefdJ            ZAdKeBde4eCe1         eDe1e1f         f         fdLZEdldMZF	 	 	 	 	 	 	 	 	 	 dsdOedPed2ed"ee	         dQedRedSedTee         dUee         dVee         ddfdWZGdefdXZH eI            dYe	dee&         fdZ            ZJdld[ZKdpd\ee	         ddfd]ZLdeMfd^ZNd_e	ddfd`ZOdePfdaZQdePfdbZRdcededePfddZSd8e$dee	dfeTdedePf
dgZUdtd@eddfdhZV	 	 dudieeDeef                  djeeDeef                  ddfdkZW xZXS )v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)selfr8   	__class__s     Q/var/www/lms/venv/lib/python3.11/site-packages/mysql/connector/connection_cext.pyrR   zCMySQLConnection.__init__r   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 r@   )str).0xs     rX   
<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updaterG   VERSIONsocketgethostname)rV   license_chunksclient_licenses      rX   _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	 	
 	
 	
 	
 	
rc   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capabilitiesru   )
rC   get_proto_infoget_server_info	thread_idst_server_capabilities
_handshake_check_server_version_server_version_character_setset_mysql_versionrV   s    rX   _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Crc   c                 4    | j                                         S )z6Returns the server status attribute of MYSQL structure)rC   st_server_statusr   s    rX   _server_statuszCMySQLConnection._server_status   s     |,,...rc   rF   c                 L    | j         r| j                             |           dS dS )zJset local_infile_in_path

        Set allow_local_infile_in_path.
        N)rC   !set_load_data_local_infile_option)rV   rF   s     rX   set_allow_local_infile_in_pathz/CMySQLConnection.set_allow_local_infile_in_path   s7     < 	AL::4@@@@@	A 	Arc   valuec                     || _         | j        r| j                            |           | j        r| j                            |           d S d S N)_use_unicoderC   use_unicoderP   set_unicoderV   r   s     rX   r   zCMySQLConnection.use_unicode   sZ    !< 	,L$$U+++> 	.N&&u-----	. 	.rc   c                 D    |                      d          d         }|dk    S )z#Get whether autocommit is on or offzSELECT @@session.autocommitr   r   
info_queryr   s     rX   
autocommitzCMySQLConnection.autocommit   s%      =>>qAzrc   c                    	 | j                             |           || _        dS # t          $ rT}t	          |d          r"t          |j        |j        |j                  |t          t          |                    |d}~ww xY w)zToggle autocommiterrnomsgsqlstateN)rC   r   _autocommitr(   hasattrr   r   r   r   r   r_   rV   r   errs      rX   r   zCMySQLConnection.autocommit   s    	4L##E***$D" 	4 	4 	4sG$$ )I37S\   !S**3	4s   !% 
BAA>>Bc                     | j         S r   )_read_timeoutr   s    rX   read_timeoutzCMySQLConnection.read_timeout   s    !!rc   timeoutc                      t          d          )Nz
            The use of read_timeout after the connection has been established is unsupported
            in the C-Extension
            r   rV   r   s     rX   r   zCMySQLConnection.read_timeout       
 
 	
rc   c                     | j         S r   )_write_timeoutr   s    rX   write_timeoutzCMySQLConnection.write_timeout   s    ""rc   c                      t          d          )Nz
            Changes in write_timeout after the connection has been established is unsupported
            in the C-Extension
            r   r   s     rX   r   zCMySQLConnection.write_timeout   r   rc   c                 8    |                      d          d         S )zGet the current databasezSELECT DATABASE()r   r   r   s    rX   databasezCMySQLConnection.database   s     233A66rc   c                     	 | j                             |           dS # t          $ rT}t          |d          r"t	          |j        |j        |j                  |t          t          |                    |d}~ww xY w)zSet the current databaser   r   N
rC   	select_dbr(   r   r   r   r   r   r   r_   r   s      rX   r   zCMySQLConnection.database   s    	4L""5)))))" 	4 	4 	4sG$$ )I37S\   !S**3	4    
A<AA77A<c                 D    t          | j        t          j        z            S )z'MySQL session has started a transaction)boolr   r   STATUS_IN_TRANSr   s    rX   in_transactionzCMySQLConnection.in_transaction
  s     D'**DDEEErc   c                 n   | 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        na# th          $ rT}tk          |d'          r"tm          |j7        |j8        |j9        (          |tu          tC          |                    |d }~ww xY w| ;                                 | j*        stk          | j        d)          r~ty          | 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   ry   
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_idrJ   MySQL	_buffered_raw_connection_timeoutr   _auth_pluginrL   rC   isset_client_flagr   CONNECT_ARGSrk   _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sortrG   _ssl_disabledrl   rE   name_auth_plugin_classrS   _converter_str_fallbackconverter_str_fallbackrP   str_fallbackr(   r   r   r   r   r   r   r   callabler   setr'   r&   )	rV   r   
cnx_kwargsr   ssl_ciphersuitesr   r   ciphertls_versions	            rX   _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,-
	4 DL ..:...262NDL/~ K.2.J+" 	4 	4 	4sG$$ )I37S\   !S**3	4 	 "	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" "
N ,AM;;N c                    | j         rE| j                                         r,t          | j         t          j                    d                    | j        sd S 	 |                                  | j                                         n}# t          $ rp}t          rt          | j         |           t          |d          r"t          |j        |j        |j                  |t          t!          |                    |d }~ww xY w	 t          rt#          | j                    d S d S # t          rt#          | j                    w w xY w)Nr   r   r   )_spanis_recordingr5   sysexc_inforC   free_resultrU   r(   r2   r   r   r   r   r   r   r_   r4   )rV   r   s     rX   rU   zCMySQLConnection.close}  sY   : 	B$*1133 	B"4:s|~~a/@AAA| 	F	%L    " 	4 	4 	4 8&tz3777sG$$ )I37S\   !S**3	4 !  %$$$$$% %| %$$$$%s+   -B D" 
C?A+C::C??D" "E c                 6    | j                                          S )z8Return True if the connection to MySQL Server is closed.)rC   	connectedr   s    rX   	is_closedzCMySQLConnection.is_closed  s    <))++++rc   c                 n    | j         r-|                                  | j                                         S dS )z;Reports whether the connection to MySQL Server is availableF)rC   handle_unread_resultpingr   s    rX   is_connectedzCMySQLConnection.is_connected  s7    < 	'%%'''<$$&&&urc   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  rC   r  AttributeErrorr  r   )rV   r  r  r  r  s        rX   r  zCMySQLConnection.ping  s     	!!###	))++I    	 	 	D	  	INNHEN::::: !GHHHs   4 
A Arw   c                 :    | j                             |           dS )z;Sets the default character set name for current connection.N)rC   set_character_set)rV   rw   s     rX   set_character_set_namez'CMySQLConnection.set_character_set_name  s    &&w/////rc   queryc                    d}	 | j                             |           | j         j        rZ| j                                         }| j                                         r(| j                                          t          d          | j                                          na# t          $ rT}t          |d          r"t          |j	        |j
        |j                  |t          t          |                    |d}~ww xY w|S )z%Send a query which only returns 1 rowr@   z'Query should not return more than 1 rowr   r   N)rC   r#  have_result_set	fetch_rowr  r   r(   r   r   r   r   r   r_   )rV   r#  	first_rowr   s       rX   r   zCMySQLConnection.info_query  s   		4Lu%%%|+ T L2244	<))++ TL,,...()RSSSL$$&&&&" 	4 	4 	4sG$$ )I37S\   !S**3	4 s   BB 
C<(AC77C<c                 Z    	 | j                                         S # t          $ r Y nw xY wdS )zMySQL connection IDN)rC   r~   r(   r   s    rX   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,          $ r}|r|                                 n|                                  t/          |d	          r"t1          |j        |j        |j        
          |t9          t;          |                    |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   )r%  unread_resultrC   r   r   r  r&  rP   r   list	enumeraterD   r   VECTORr   _vector_to_python	to_pythonappendtuplefetch_eof_columnsr  _unread_resultr(   r   r   r   r   r   r   r_   )rV   r*  r+  r,  r   r-  r8   r0  rowscounterr&  rowidsc__eofr   s                    rX   get_rowszCMySQLConnection.get_rows  s    6?V	11DDV 	; 	; 9:::;)C! !GHHH:	4/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''$$&&&&" 		4 		4 		4 #%%''''  """sG$$ )I37S\   !S**3		4 Tzs   FG. .
I78A:I22I7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   )r*  r+  r,  r   r-  r   NNN)rA  
IndexError)rV   r+  r,  r   r-  r8   r:  r/  s           rX   get_rowzCMySQLConnection.get_row5  sv    	 # &  ID#  &Q~%#; 	  	  	 <<	 s   (/ / 
==c                 x    | j         r2| j                                          | j                                         S dS )zReads the next resultN)rC   consume_resultnext_resultr   s    rX   rH  zCMySQLConnection.next_resultM  s9    < 	.L'')))<++---trc   c                 J    | j         r| j                                          dS dS )zFrees the resultN)rC   r  r   s    rX   r  zCMySQLConnection.free_resultT  s0    < 	'L$$&&&&&	' 	'rc   c                 r    | j         r/|                                  | j                                          dS dS )zCommit current transactionN)rC   r  commitr   s    rX   rK  zCMySQLConnection.commitY  sB    < 	"%%'''L!!!!!	" 	"rc   c                 |    | j         r4| j                                          | j                                          dS dS )zRollback current transactionN)rC   rG  rollbackr   s    rX   rM  zCMySQLConnection.rollback_  sD    < 	$L'')))L!!#####	$ 	$rc   r   c                     	 | j                             |           dS # t          $ rT}t          |d          r"t	          |j        |j        |j                  |t          t          |                    |d}~ww xY w)zChange the current databaser   r   Nr   )rV   r   r   s      rX   cmd_init_dbzCMySQLConnection.cmd_init_dbe  s    	4L""8,,,,," 	4 	4 	4sG$$ )I37S\   !S**3	4r   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)r/  r,  )r%  rC   r   fetch_fieldsrD   r6  intr   NOT_NULLr   st_warning_count)rV   r-  r%  fieldscols        rX   r8  z"CMySQLConnection.fetch_eof_columnsp  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!%!>!>!@!@  }
 
 	
rc   c                     | j         ri| j                                         | j                                         | j                                         | j                                         | j        dS dS )z Fetch EOF and status information)rW  field_count	insert_idaffected_rowsrx   N)rC   r[  st_field_countr`  ra  r   r   s    rX   fetch_eof_statusz!CMySQLConnection.fetch_eof_status  sl    < 	!%!>!>!@!@#|::<<!\3355!%!;!;!=!=!%!4   trc   	statementc                 \   | j         st          d          	 | j                             |          }| j        |_        t          |          S # t          $ rT}t          |d          r"t          |j	        |j
        |j                  |t          t          |                    |d}~ww xY w)zPrepares the SQL statementMySQL Connection not availabler   r   N)rC   r   stmt_preparer  r  r   r(   r   r   r   r   r   r   r_   )rV   rd  r8   stmtr   s        rX   cmd_stmt_preparez!CMySQLConnection.cmd_stmt_prepare  s     | 	E"#CDDD		4<,,Y77D*.*FD'!$'''" 	4 	4 	4sG$$ )I37S\   !S**3	4s   4A 
B+AB&&B+statement_idargsc                 v   	  |j         |d| j        i na# t          $ rT}t          |d          r"t	          |j        |j        |j                  |t          t          |                    |d}~ww xY wg | _
        |j        sd| _        |                                 S d| _        |                     |          S )zExecutes the prepared statementquery_attrsr   r   NFT)stmt_executerm  r(   r   r   r   r   r   r   r_   rD   r%  r9  rc  r8  )rV   rj  rk  r8   r   s        rX   cmd_stmt_executez!CMySQLConnection.cmd_stmt_execute  s    	4%L%tJ9IJJJJ" 	4 	4 	4sG$$ )I37S\   !S**3	4 + 	+"'D((***"%%l333s    
A3AA..A3c                    | j         rt          d          	 |                                 dS # t          $ rT}t	          |d          r"t          |j        |j        |j                  |t          t          |                    |d}~ww xY w)zCloses the prepared statementUnread result foundr   r   N)r9  r   
stmt_closer(   r   r   r   r   r   r   r_   rV   rj  r8   r   s       rX   cmd_stmt_closezCMySQLConnection.cmd_stmt_close        	7 5666	4##%%%%%" 	4 	4 	4sG$$ )I37S\   !S**3	4   . 
BABBc                    | j         rt          d          	 |                                 dS # t          $ rT}t	          |d          r"t          |j        |j        |j                  |t          t          |                    |d}~ww xY w)zResets the prepared statementrq  r   r   N)r9  r   
stmt_resetr(   r   r   r   r   r   r   r_   rs  s       rX   cmd_stmt_resetzCMySQLConnection.cmd_stmt_reset  ru  rv  r   raw_as_stringc                    |                                   || j        }	 t          |t                    s|                    d          }|| _        d | _        | j                            ||||| j	                   n# t          $ rT}t          |d          r"t          |j        |j        |j                  |t!          t#          |                    |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   rz  rm  r   r   :i  zConnection not available.)r   values)r  r   r   bytesencode_query_local_infile_filenamesrC   r#  rm  r(   r   r   r   r   r   r   r_   r  r   r   r   r   rD   r%  rc  r8  )rV   r#  r   r   rz  r8   r   addrs           rX   	cmd_queryzCMySQLConnection.cmd_query  s    	!!###;)C	eU++ .W--  DK+/D(L!+ ,      # 	4 	4 	4sG$$ )I37S\   !S**3 	 	 	%)%6X!!tz<X<XDJ<X<X  #D*E#F  		 |+ 	+((***%%'''s%   AA< <
DACD"3DDpreparedcursor_class
dictionaryr   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  
t          t          t          t          t          t          t           t"          d}	  |
         |           S # t$          $ rC d	t'          dd                    	
fdt+          d
          D                       z             dw xY 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      rR     )r   r   r  rd   rR     r     )r   r   r  r  z*Cursor not available with given criteria: z, c                 8    g | ]}d |z  z  dk    |         S )r   r   r@   )r`   r=  rk  cursor_types     rX   rb   z+CMySQLConnection.cursor.<locals>.<listcomp>t  s1    VVV+a:PTU:U:UT!W:U:U:Urc   )r  r  r   warningswarnWarning
issubclassr)   r   r   r   r*   r0   r,   r-   r+   r.   r/   KeyError
ValueErrorrG   range)rV   r   r   r  r  r  r   r   typesrk  r  s            @@rX   cursorzCMySQLConnection.cursor"  s   J 	!!(+++  "" 	F"#DEEE 	= 	M&    
 #lL99 &S   !L$'''-t~TYt1K$;;1K1Kt2K #&'$(	
 	
	&E+&--- 	 	 	@D<))VVVVVeAhhVVVWWX  	s   7D AEc                 j    | j         j        st          d          | j                                         S )z,Returns number of rows of current result setrQ  )rC   r%  r   num_rowsr   s    rX   r  zCMySQLConnection.num_rowsw  s3     |+ 	2 111|$$&&&rc   c                 F    | j         sdS | j                                         S )zReturns number of warningsr   )rC   rW  r   s    rX   rW  zCMySQLConnection.warning_count  s'     | 	1|))+++rc   c                 ,    | j         sdS | j         j        S )z"Check if a result set is availableF)rC   r%  r   s    rX   result_set_availablez%CMySQLConnection.result_set_available  s     | 	5|++rc   c                     | j         S )z)Check if there are unread results or rows)r  r   s    rX   r0  zCMySQLConnection.unread_result  s     ((rc   c                 4    | j                                         S )zCheck if there are more results)rC   more_resultsr   s    rX   r  zCMySQLConnection.more_results  s     |((***rc   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 r@   )rP   quoteescapeto_mysql	_sql_mode)r`   r   rV   s     rX   rb   z6CMySQLConnection.prepare_for_mysql.<locals>.<listcomp>  si         N((-- N33E::DN    rc   r   zCould not process parameters: (z)), it must be of type list, tuple or dict)r   r1  r7  rP   rC   convert_to_mysqldictitemsr  r  r  r  r  r   type__name__)rV   r  resultr   r   s   `    rX   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 : : : : :  
 rc   c                 8    | j                                          dS )zlConsume the current result

        This method consume the result by reading (consuming) all rows.
        N)rC   rG  r   s    rX   consume_resultsz CMySQLConnection.consume_results  s    
 	##%%%%%rc    usernamer   r   r   r   r   r   r   c                    	 | j                             ||||||||	|
	  	         na# t          $ rT}t          |d          r"t	          |j        |j        |j                  |t          t          |                    |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   r   Nzcharset must be an integerr   z2charset should be either zero or a postive integer)rC   change_userr(   r   r   r   r   r   r   r_   r   rY  r  r   r   _post_connection)rV   r  r   r   rw   r   r   r   r   r   r   r   s               rX   cmd_change_userz CMySQLConnection.cmd_change_user  s   	4L$$"!
 
 
 
 # 	4 	4 	4sG$$ )I37S\   !S**3	4 gs++ ? !=>>>{{ !UVVV&D
s   "% 
BAA>>B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
        )rC   reset_connectionr  )rV   ress     rX   cmd_reset_connectionz%CMySQLConnection.cmd_reset_connection  s6     l++-- 	$!!###
rc   optionsc                 L   	 |                                   | j                            |           na# t          $ rT}t	          |d          r"t          |j        |j        |j                  |t          t          |                    |d }~ww xY w|                                 S )Nr   r   )r  rC   refreshr(   r   r   r   r   r   r   r_   rc  )rV   r  r   s      rX   cmd_refreshzCMySQLConnection.cmd_refresh  s    	4%%'''L  ))))" 	4 	4 	4sG$$ )I37S\   !S**3	4 $$&&&s   .1 
BAB

Bc                 .    |                                   dS )z,Close the current connection with the serverN)rU   r   s    rX   cmd_quitzCMySQLConnection.cmd_quit  s    

rc   shutdown_typec                    | j         st          d          |r&t          j        |          st	          d          |}nt          j        }	 | j                             |           na# t          $ rT}t          |d          r"t          |j
        |j        |j                  |t	          t          |                    |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.
        rf  zInvalid shutdown typer   r   N)rC   r   r   r   r   SHUTDOWN_DEFAULTshutdownr(   r   r   r   r   r   r_   rU   )rV   r  levelr   s       rX   cmd_shutdownzCMySQLConnection.cmd_shutdown  s     | 	E"#CDDD 	2(77 >$%<===!EE 1E	4L!!%((((" 	4 	4 	4sG$$ )I37S\   !S**3	4 	

s   A' '
C1AC  Cc                 t   |                                   	 | j                                        }t                                          |d          S # t
          t          f$ rT}t          |d          r"t          |j	        |j
        |j                  |t          t          |                    |d}~ww xY w)z'Return statistics from the MySQL serverF)with_headerr   r   N)r  rC   statr   parse_statisticsr(   r   r   r   r   r   r   r_   )rV   r  r   s      rX   cmd_statisticszCMySQLConnection.cmd_statistics1  s    !!###	4<$$&&D ??33De3LLL#^4 	4 	4 	4sG$$ )I37S\   !S**3	4s   ;A B7#AB22B7	mysql_pidc                 ~    t          |t                    st          d          |                     d|            dS )zKill a MySQL processzMySQL PID must be intzKILL N)r   rY  r  r  )rV   r  s     rX   cmd_process_killz!CMySQLConnection.cmd_process_kill?  sD    )S)) 	64555*y**+++++rc   c                     t           )zSend the DEBUG commandNotImplementedErrorr   s    rX   	cmd_debugzCMySQLConnection.cmd_debugE      !!rc   c                     t           )zSend the PING commandr  r   s    rX   cmd_pingzCMySQLConnection.cmd_pingI  r  rc   
statementsc                     t           )z/Send one or more statements to the MySQL serverr  )rV   r  r8   s      rX   cmd_query_iterzCMySQLConnection.cmd_query_iterM  r  rc   param_iddatac                     t           )zSend data for a columnr  )rV   rj  r  r  r8   s        rX   cmd_stmt_send_long_dataz(CMySQLConnection.cmd_stmt_send_long_dataQ  s
     "!rc   c                     |du r| j         n| j        }| j        r|                                  dS |rt	          d          dS )z'Check whether there is an unread resultTrq  N)r9  r0  can_consume_resultsr  r   )rV   r  r0  s      rX   r  z%CMySQLConnection.handle_unread_result[  s`    /74/?/?++TEW# 	7  """"" 	7 5666	7 	7rc   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  executerU   )rV   r  r  curr   r   s         rX   reset_sessionzCMySQLConnection.reset_sessionc  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%)r9   N)Fr   r   )NFNNN)FNNNr   )NFF)NNNNNNN)
r  r  r  Nr  r  r  NNN)FrC  )Yr  
__module____qualname____doc__r   rR   rr   r   propertyrY  r   r_   r   r   r   setterr   r   r   r   r   r   r   r  rU   
disconnectr  r  r  r"  r$   r"   r   r)  r   r    r   r
   r   rA  rE  rH  r  rK  rM  rO  r   r8  rc  r~  ri  r3   r   ro  rt  ry  r  _execute_queryr   r)   r  r  rW  r  r0  r  r!   r	   r   r  r  r  r  r   r  r  r  r#   r  r  r   r  r  r  r   r  r  r  __classcell__)rW   s   @rX   r7   r7   o   s       @@       B
 
 
 
"D D D D$ / / / / X/A3 A4 A A A A (/. .$ . . . 0/. D    X
 
4 
4 
4 
4 
4 
4 "hsm " " " X" 
C 
D 
 
 
 
 #x} # # # X# 
S 
T 
 
 
 
 7# 7 7 7 X7 _	4c 	4d 	4 	4 	4 _	4 F F F F XFlB lB lB lB\% % % %. 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R R}R R $/0	R
 d^R N+R R 
tG}h'899	:R R R Rl 37".2     $/0  d^	 
 N+    
x (+<"==	>       0Xd^    ' ' ' '
" " " "$ $ $ $	4C 	4D 	4 	4 	4 	4 59!
 !
!.1!
	!
 !
 !
 !
F(+<"=    44 4 
	4 4 4 4( 4$4 4 	4
 
%)>9:	;4 4 4 424$4 4 
	4 4 4 4"4$4 4 
	4 4 4 4"  ##-( -(-( d^-( 	-(
 -( -( 
%)>9:	;-( -( -( -(^ N $("#'59%)&*'+S S4.S d^S 4.	S
 tL12S TNS smS  }S 
S S S Sj '# ' ' ' X' ,s , , , X, ,d , , , X, )t ) ) ) X) +d + + + X+).)	xUE\ 22	3) ) ) )V& & & & !%)-,0+/+  + +  +  	+ 
 #+  +  +  +  "#+  %SM+  $C=+  
+  +  +  + Zd      !!'3 '84E+F ' ' ' "!'    (3- 4    44 4 4 4 4,# ,$ , , , ,"8 " " " ""( " " " "" " " " " " ""$" " 	"
 " 
" " " "7 7T 7d 7 7 7 7 486:/ / c3h0/ $DcN3/ 
	/ / / / / / / /rc   r7   )Jr  rE   rM   rn   r  r  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   rt   r   r  r   r   r    r!   r"   r#   r$   utilsr%   r&   r'   rA   rJ   r(   cursor_cextr)   r*   r+   r,   r-   r.   r/   r0   ImportErrorexcopentelemetry.constantsr2   !opentelemetry.context_propagationr3   opentelemetry.instrumentationr4   r5   r7   r@   rc   rX   <module>r     ss  > . - 				   



                               3 3 3 3 3 3 > > > > > > > > Q Q Q Q Q Q Q Q Q Q Q Q Q Q & & & & & &              $ # # # # #                           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c c c c c. c c c c cs   
 B+ +C0C  C