
    ,hȡ                        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Z4ddlBmCZC ddlDmEZE eCrddlFmGZGmHZH  G d de      ZIy# e@$ rZA e@deA d      eAdZA[Aww xY w)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dhdZdhd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dhdZdhdZeZdefdZdefdZdid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!	 	 	 	 	 djd$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'	 	 	 	 dkd%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)dhd,Z*dhd-Z+dhd.Z,d/eddfd0Z-	 dld(ee$   de.fd1Z/dee&   fd2Z0d3e1dede$fd4Z2e3d5e$d6ededee4e&e.f      fd7       Z5d5e$deddfd8Z6d5e$deddfd9Z7e3	 	 	 dmd!ed'ee   d:ed;ededee4e&e.f      fd<       Z8e8Z9	 	 	 	 	 	 	 dnd:ee   d'ee   d=ee   d>ee:e;      d?ee   d@ee	   dAee	   de;fdBZ<ede	fdC       Z=ede	fdD       Z>edefdE       Z?edefdF       Z@edefdG       ZAdHeBde4eCe1   eDe1e1f   f   fdIZEdhdJZF	 	 	 	 	 	 	 	 	 	 dodKedLed/edee	   dMedNedOedPee   dQee   dRee   ddfdSZGdefdTZH eI       dUe	dee&   fdV       ZJdhdWZKdldXee	   ddfdYZLdeMfdZZNd[e	ddfd\ZOdePfd]ZQdePfd^ZRd_ededePfd`ZSd5e$dae	dbeTdedePf
dcZUdpd=eddfddZV	 	 dqdeeeDeef      dfeeDeef      ddfdgZW xZXS )rCMySQLConnectionz6Class initiating a MySQL Connection using Connector/C.kwargsreturnNc                    t         st        d      d| _        g | _        t        j
                  j                  t        j
                  j                  t        j
                  j                  t        j                              ddd      | _        t        j                         dk(  rQt        j
                  j                  | j                        s(t        j
                  j                  d      rdnd| _        d| _        t         | E          |r	  | j$                  d	i | yy# t&        $ r | j)                           w xY w)
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     a/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/mysql/connector/connection_cext.pyrR   zCMySQLConnection.__init__r   s   QRR  	 02 "GGOOBGGOO,<,E,EFG	!
 ??'77>>$"2"23 ww~~&?@ .0   48&v&   

s   D$ $D?c                 8   t         j                  j                  d      }|d   dk(  rd}nd}| j                  j	                  d|dj                  t         j                  dd D cg c]  }t        |       c}      t        j                         d	       y
c c}w )z!Add default connection attributes r   GPLv2zGPL-2.0
Commercialzmysql-connector-python.   )_connector_name_connector_license_connector_version_source_hostN)
r   LICENSEsplit_conn_attrsupdaterG   VERSIONstrsocketgethostname)rV   license_chunksclient_licensexs       rX   _add_default_conn_attrsz(CMySQLConnection._add_default_conn_attrs   s     ..s3!'&N)N#;&4&)hhPQRS@T/U1A/U&V & 2 2 4		
 0Vs   $Bc           	      t   | j                   j                         | j                   j                         | j                   j                         dddd| j                   j	                         d| _        | j                  | j
                  d         | _        | j                  j                  | j                         y)z<Gather information of the MySQL server before authenticationN)protocolserver_version_originalserver_threadidcharsetserver_statusauth_plugin	auth_datacapabilitiesrq   )
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'+||'C'C'E#||557! LL??A	
  $99OO56 
 	--d.B.BC    c                 6    | j                   j                         S )z6Returns the server status attribute of MYSQL structure)rC   st_server_statusr   s    rX   _server_statuszCMySQLConnection._server_status   s     ||,,..r   rF   c                 T    | j                   r| j                   j                  |       yy)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   s"     <<LL::4@ r   valuec                     || _         | j                  r| j                  j                  |       | j                  r| j                  j	                  |       y y N)_use_unicoderC   use_unicoderP   set_unicoderV   r   s     rX   r   zCMySQLConnection.use_unicode   sA    !<<LL$$U+>>NN&&u- r   c                 4    | j                  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r   c                    	 | j                   j                  |       || _        y# t        $ rS}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   rh   rV   r   errs      rX   r   zCMySQLConnection.autocommit   sq    	4LL##E*$D" 	4sG$)II377S\\ !S*3	4s   "% 	BAA<<Bc                     | j                   S r   )_read_timeoutr   s    rX   read_timeoutzCMySQLConnection.read_timeout   s    !!!r   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       
 	
r   c                     | j                   S r   )_write_timeoutr   s    rX   write_timeoutzCMySQLConnection.write_timeout   s    """r   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   r   c                 *    | j                  d      d   S )zGet the current databasezSELECT DATABASE()r   r   r   s    rX   databasezCMySQLConnection.database   s     23A66r   c                     	 | j                   j                  |       y# t        $ rS}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   rh   r   s      rX   r   zCMySQLConnection.database   si    	4LL""5)" 	4sG$)II377S\\ !S*3	4    	A:AA55A:c                 N    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DEEr   c                 	   | j                   j                  | j                        d   }t        j                  | j
                  | j                  || j                  xs d| j                  | 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| j0                  d| j2                  d| j4                  ddd| j                  d| j6                  d| j8                  d| j:                  d| j<                  t?        | j@                  tB              rtE        | j@                        n| j@                  | jF                  | jH                  r| jH                  nd| jJ                  r| jJ                  ndd}| jL                  jO                  d      }|#|jQ                  d       djS                  |      }| jL                  jO                  d      A| jL                  jO                  d      d   xs d }| jL                  jO                  d      d   }nd }d }|d|v r|sd}| jT                  s|jW                  | jL                  jO                  d      | jL                  jO                  d      | jL                  jO                  d      |||| jL                  jO                  d       xs d!| jL                  jO                  d"      xs d!| jT                  d#	       tX        jZ                  d$k(  r| j\                  d%k(  rd|d&<   	  | j                  j^                  d*i | | j`                  | j                  _1        | jd                  r| j`                  | jd                  _3        | jw                          | jT                  stk        | j                  d)      r|ty        | j                  jz                        r\| j                  j{                         }t}        | jL                  jO                  dg             D ]  }t        |       t        ||        y y y y # th        $ rS}tk        |d'      r-tm        |jn                  |jp                  |jr                  (      |tu        tC        |            |d }~ww xY w)+Nr   )bufferedrawcharset_nameconnection_timeoutr   ru   
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_ARGSre   _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_callbackrh   r%   _openid_token_filer   r   _sslgetsortrG   _ssl_disabledrf   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3D4D4DEaH'--^^		% $ 8 8 =A(())''
 %%j&=&=>!D
DJJ
DJJ
 
 	

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

8 yy}}^4#d+88L1L99==+,8		01!4<   $yy}}-?@   $#$\)$7!!"iimmD1 $		f 5#yy}}U3)9$0)9'+yy}}]'C'Lu+/99==9J+K+Tu$($6$6
 77d?t66:SS04J,-
	4 DLL  .:.262N2NDLL/~~.2.J.J+ 	 ""&67445 \\002F"499==#DE B+K8,V[AB 6 8 # # 	4sG$)II377S\\ !S*3	4s   AR 	S1AS,,S1c                    | j                   rE| j                   j                         r+t        | j                   t        j                         d          | j
                  sy 	 | j                          | j
                  j                          	 t        rt#        | j                          y y # t        $ ro}t        rt        | j                   |       t        |d      r-t        |j                  |j                  |j                        |t        t!        |            |d }~ww xY w# 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   rh   r4   )rV   r   s     rX   rU   zCMySQLConnection.close}  s    ::$**113"4::s||~a/@A||	%LL  $  # 	4&tzz37sG$)II377S\\ !S*3	4 $ s%    *B( (	D 1A*DD  D# #Ec                 8    | j                   j                          S )z8Return True if the connection to MySQL Server is closed.)rC   	connectedr   s    rX   	is_closedzCMySQLConnection.is_closed  s    <<))+++r   c                 p    | j                   r*| j                          | j                   j                         S y)z;Reports whether the connection to MySQL Server is availableF)rC   handle_unread_resultpingr   s    rX   is_connectedzCMySQLConnection.is_connected  s+    <<%%'<<$$&&r   	reconnectattemptsdelayc                     | j                          	 | j                  j                         }|ry|r| j	                  ||       yt        d      # t        $ r Y ,w xY w)a  Check availability of the MySQL server

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

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

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

        Raises InterfaceError on errors.
        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  sb     	!!#	))+I NNHEN: !GHH  		s   A 	AArs   c                 :    | j                   j                  |       y)z;Sets the default character set name for current connection.N)rC   set_character_set)rV   rs   s     rX   set_character_set_namez'CMySQLConnection.set_character_set_name  s    &&w/r   queryc                    d}	 | j                   j                  |       | j                   j                  rY| j                   j                         }| j                   j                         r%| j                   j	                          t        d      | j                   j	                          |S # t        $ rS}t        |d      r-t        |j                  |j                  |j                        |t        t        |            |d}~ww xY w)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   rh   )rV   r   	first_rowr   s       rX   r   zCMySQLConnection.info_query  s    		4LLu%||++ LL224	<<))+LL,,.()RSSLL$$&  # 	4sG$)II377S\\ !S*3	4s   B$B* *	D3ADDc                 V    	 | j                   j                         S # t        $ r Y yw xY w)zMySQL connection IDN)rC   rz   r(   r   s    rX   connection_idzCMySQLConnection.connection_id  s/    	<<))++" 		s    	((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                  j                  d        |
       }|rt        |      }| j                  j                         sQ|sOt        | j                        D ]7  \  }}|d   t        j                  k(  st        j                  ||         ||<   9 | j                  sQ| j                  rEt        |      D ]7  \  }}|r	| j                  j!                  | j                  |   ||         ||<   9 |j#                  t%        |             |	dz  }	|r|	|k(  rn |
       }|r|s?| j'                  |      d   }|r|j)                          d| _        n| j)                          nd}||fS # t,        $ rv}|r|j)                          n| j)                          t/        |d	      r-t1        |j2                  |j4                  |j6                  
      |t9        t;        |            |d}~ww xY 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_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   rh   )rV   r'  r(  r)  r   r*  r8   r-  rowscounterr#  rowidsc__eofr   s                    rX   get_rowszCMySQLConnection.get_rows  sQ    6?	11DDVDV 9::;))C! !GHH:	4/8	++dll>T>TI~~   &+C3i||'')# #,DMM": N3q6Y%5%55%3%E%Ec!f%MCFN yyT^^ )# X1"%)^^%=%=dmmA>NPSTUPV%WCFX E#J'1W-k9 : 484J4J94U5 ))+*/D'$$& Tz # 		4%%'  "sG$)II377S\\ !S*3		4s/   B/G< 	AG< A!G< 5AG< <	I;A1I66I;c                 n    	 | j                  d||||      \  }}|r|d   |fS d|fS # t        $ r Y yw xY w)z.Get the next rows returned by the MySQL serverr   )r'  r(  r)  r   r*  r   NNN)r>  
IndexError)rV   r(  r)  r   r*  r8   r7  r,  s           rX   get_rowzCMySQLConnection.get_row5  s\    	 # & ID# Q~%#; 	 	 s   !( ( 	44c                     | j                   r4| j                   j                          | j                   j                         S y)zReads the next resultN)rC   consume_resultnext_resultr   s    rX   rE  zCMySQLConnection.next_resultM  s/    <<LL'')<<++--r   c                 R    | j                   r| j                   j                          yy)zFrees the resultN)rC   r  r   s    rX   r  zCMySQLConnection.free_resultT  s    <<LL$$& r   c                 r    | j                   r+| j                          | j                   j                          yy)zCommit current transactionN)rC   r  commitr   s    rX   rH  zCMySQLConnection.commitY  s*    <<%%'LL! r   c                     | j                   r5| j                   j                          | j                   j                          yy)zRollback current transactionN)rC   rD  rollbackr   s    rX   rJ  zCMySQLConnection.rollback_  s.    <<LL'')LL!!# r   r   c                     	 | j                   j                  |       y# t        $ rS}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  si    	4LL""8," 	4sG$)II377S\\ !S*3	4r   c                    |r|j                   n| j                  j                   }|st        d      |r|j                         n| j                  j                         }g | _        |D ]k  }| j                  j                  |d   t        |d         ddddt        |d          t        j                  z  t        |d         t        |d         f	       m | j                  | 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   r3  intr   NOT_NULLr   st_warning_count)rV   r*  r"  fieldscols        rX   r5  z"CMySQLConnection.fetch_eof_columnsp  s    
 *3I%%8T8T 	  11-6'')DLL<U<U<W 	CMM  FAKQ[L9#5#55AKAK
	"  $22!%!>!>!@ }}
 	
r   c                     | j                   rr| j                   j                         | j                   j                         | j                   j                         | j                   j	                         | j
                  dS y)z Fetch EOF and status information)rT  field_count	insert_idaffected_rowsrt   N)rC   rX  st_field_countr]  r^  r   r   s    rX   fetch_eof_statusz!CMySQLConnection.fetch_eof_status  sa    <<!%!>!>!@#||::<!\\335!%!;!;!=!%!4!4  r   	statementc                 ^   | j                   st        d      	 | j                   j                  |      }| j                  |_        t        |      S # t        $ rS}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   rh   )rV   ra  r8   stmtr   s        rX   cmd_stmt_preparez!CMySQLConnection.cmd_stmt_prepare  s     ||"#CDD		4<<,,Y7D*.*F*FD'!$''" 	4sG$)II377S\\ !S*3	4s   6A 	B,AB''B,statement_idargsc                 ~   	  |j                   |d| j                  i g | _
        |j                  sd| _        | j                         S d| _        | j                  |      S # t        $ rS}t        |d      r-t	        |j
                  |j                  |j                        |t        t        |            |d}~ww xY w)zExecutes the prepared statementquery_attrsr   r   NFT)stmt_executerj  r(   r   r   r   r   r   r   rh   rD   r"  r6  r`  r5  )rV   rg  rh  r8   r   s        rX   cmd_stmt_executez!CMySQLConnection.cmd_stmt_execute  s    	4%L%%tJ9I9IJ ++"'D((**"%%l33 # 	4sG$)II377S\\ !S*3	4s   A   	B<)AB77B<c                    | j                   rt        d      	 |j                          y# t        $ rS}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)r6  r   
stmt_closer(   r   r   r   r   r   r   rh   rV   rg  r8   r   s       rX   cmd_stmt_closezCMySQLConnection.cmd_stmt_close  z      566	4##%" 	4sG$)II377S\\ !S*3	4   * 	BABBc                    | j                   rt        d      	 |j                          y# t        $ rS}t	        |d      r-t        |j                  |j                  |j                        |t        t        |            |d}~ww xY w)zResets the prepared statementrn  r   r   N)r6  r   
stmt_resetr(   r   r   r   r   r   r   rh   rp  s       rX   cmd_stmt_resetzCMySQLConnection.cmd_stmt_reset  rr  rs  r   raw_as_stringc                    | j                          || j                  }	 t        |t              s|j	                  d      }|| _        d | _        | j                  j                  ||||| j                         g | _        | j                  j0                  s| j3                         S | j5                         S # t        $ rS}t        |d      r-t        |j                  |j                  |j                        |t!        t#        |            |d }~wt$        $ rH}| j&                  r| j&                  n| j(                   d| j*                   }t-        d|df      |d }~ww xY w)	Nzutf-8)r   r   rw  rj  r   r   :i  zConnection not available.)r   values)r  r   r   bytesencode_query_local_infile_filenamesrC   r   rj  r(   r   r   r   r   r   r   rh   r  r   r   r   r   rD   r"  r`  r5  )rV   r   r   r   rw  r8   r   addrs           rX   	cmd_queryzCMySQLConnection.cmd_query  sO    	!!#;))C	eU+W-  DK+/D(LL!+ ,,  * ||++((**%%''' # 	4sG$)II377S\\ !S*3 	%)%6%6!!tzzl!DJJ<<X  #D*E#F		s&   AB6 6	E!?ADE!AEE!preparedcursor_class
dictionaryr   r   c                    | j                  |       | j                         st        d      |s|rt        j                  dt
               |#t        |t              st        d       ||       S |xs | j                  }|xs | 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$        $ rM d}
t'        ddj)                  t+        d
      D cg c]  }|d|z  z  dk7  s|
|    nc c}w c}      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      rO     )r   r   r  r^   rO     r     )r   r   r  r  z*Cursor not available with given criteria: z, )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   cursor_typetypesrh  r:  s               rX   cursorzCMySQLConnection.cursor"  su   J 	!!(+  ""#DEE=MM& 
 #lL9&S  !$''-t~~TYYt1K$;1K1Kt2K #&'$(	
	&E+&-- 	@D<))eAhV+a:PTU:UT!WVVWX 	s   #
C. .)ED0(D0/Ec                 x    | j                   j                  st        d      | j                   j                         S )z,Returns number of rows of current result setrN  )rC   r"  r   num_rowsr   s    rX   r  zCMySQLConnection.num_rowsw  s/     ||++ 11||$$&&r   c                 P    | j                   sy| j                   j                         S )zReturns number of warningsr   )rC   rT  r   s    rX   rT  zCMySQLConnection.warning_count  s!     ||||))++r   c                 H    | j                   sy| j                   j                  S )z"Check if a result set is availableF)rC   r"  r   s    rX   result_set_availablez%CMySQLConnection.result_set_available  s     ||||+++r   c                     | j                   S )z)Check if there are unread results or rows)r  r   s    rX   r-  zCMySQLConnection.unread_result  s     (((r   c                 6    | j                   j                         S )zCheck if there are more results)rC   more_resultsr   s    rX   r  zCMySQLConnection.more_results  s     ||((**r   paramsc           
      v   g }t        |t        t        f      r| j                  rg|D cg c]Z  }| j                  j	                  | j                  j                  | j                  j                  |      | j                              \ }}|S  | j                  j                  | }|S t        |t              ri }| j                  r|j                         D ]n  \  }}| j                  j	                  | j                  j                  | j                  j                  |      | j                              ||j                         <   p |S |j                         D ]4  \  }}| j                  j                  |      d   ||j                         <   6 |S t        dt        |      j                   d| d      c c}w )zPrepare parameters for statements

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

        Returns dict.
        r   zCould not process parameters: (z)), it must be of type list, tuple or dict)r   r.  r4  rP   quoteescapeto_mysql	_sql_moderC   convert_to_mysqldictitemsr|  r   type__name__)rV   r  resultr   r   s        rX   prepare_for_mysqlz"CMySQLConnection.prepare_for_mysql  s    :<ftUm,~~ "(  NN((-- NN33E:DNN 8 ' 766?& % %F~~"(,,. JC+/>>+?+?-- NN33E:DNN,F3::<(  #),,. SJC+/<<+H+H+OPQ+RF3::<(S  #0f1F1F0Gq Q: : /s   AF6c                 8    | j                   j                          y)zlConsume the current result

        This method consume the result by reading (consuming) all rows.
        N)rC   rD  r   s    rX   consume_resultsz CMySQLConnection.consume_results  s    
 	##%r   usernamer   r   r   r   r   r   r   c                    	 | j                   j                  ||||||||	|
	       |2t        |t              st        d      |dk  rt        d      || _        || _        | j                          y# t        $ rS}t        |d      r-t	        |j
                  |j                  |j                        |t        t        |            |d}~ww xY w)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   rh   r   rV  r  r   r   _post_connection)rV   r  r   r   rs   r   r   r   r   r   r   r   s               rX   cmd_change_userz CMySQLConnection.cmd_change_user  s    	4LL$$"!
* gs+ !=>>{ !UVV&D
! # 	4sG$)II377S\\ !S*3	4s   #A1 1	C:ACCc                 ^    | j                   j                         }|r| j                          |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  s*     ll++-!!#
r   optionsc                 8   	 | j                          | j                  j                  |       | j                         S # t        $ rS}t	        |d      r-t        |j                  |j                  |j                        |t        t        |            |d }~ww xY w)Nr   r   )r  rC   refreshr(   r   r   r   r   r   r   rh   r`  )rV   r  r   s      rX   cmd_refreshzCMySQLConnection.cmd_refresh  s    	4%%'LL  ) $$&& # 	4sG$)II377S\\ !S*3	4s   += 	BABBc                 $    | j                          y)z,Close the current connection with the serverN)rU   r   s    rX   cmd_quitzCMySQLConnection.cmd_quit  s    

r   shutdown_typec                    | j                   st        d      |r#t        j                  |      st	        d      |}nt        j
                  }	 | j                   j                  |       | j                          y# t        $ rS}t        |d      r-t        |j                  |j                  |j                        |t	        t        |            |d}~ww xY w)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.
        rc  zInvalid shutdown typer   r   N)rC   r   r   r   r   SHUTDOWN_DEFAULTshutdownr(   r   r   r   r   r   rh   rU   )rV   r  levelr   s       rX   cmd_shutdownzCMySQLConnection.cmd_shutdown  s     ||"#CDD((7$%<==!E 11E	4LL!!%( 	

 # 	4sG$)II377S\\ !S*3	4s   A: :	CACCc                 X   | j                          	 | j                  j                         }t               j	                  |d      S # t
        t        f$ rS}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   rh   )rV   r  r   s      rX   cmd_statisticszCMySQLConnection.cmd_statistics1  s    !!#	4<<$$&D ?33De3LL#^4 	4sG$)II377S\\ !S*3	4s   4A B)AB$$B)	mysql_pidc                 b    t        |t              st        d      | j                  d|        y)zKill a MySQL processzMySQL PID must be intzKILL N)r   rV  r  r  )rV   r  s     rX   cmd_process_killz!CMySQLConnection.cmd_process_kill?  s+    )S)455yk*+r   c                     t         )zSend the DEBUG commandNotImplementedErrorr   s    rX   	cmd_debugzCMySQLConnection.cmd_debugE      !!r   c                     t         )zSend the PING commandr  r   s    rX   cmd_pingzCMySQLConnection.cmd_pingI  r  r   
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  r   param_iddatac                     t         )zSend data for a columnr  )rV   rg  r  r  r8   s        rX   cmd_stmt_send_long_dataz(CMySQLConnection.cmd_stmt_send_long_dataQ  s
     "!r   c                     |du r| j                   n| j                  }| j                  r| j                          y|rt	        d      y)z'Check whether there is an unread resultTrn  N)r6  r-  can_consume_resultsr  r   )rV   r  r-  s      rX   r  z%CMySQLConnection.handle_unread_result[  sE    /74/?++TEWEW##  " 566 r   user_variablessession_variablesc                    | j                         st        d      | j                         st	 | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  	       |s|r| j                         }|r/|j!                         D ]  \  }}|j#                  d| d|f        |r/|j!                         D ]  \  }}|j#                  d| d|f        |j%                          yy# t        $ r | j                          Y w xY w)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  s0   (   ""#DEE((*!$$JJNNNN$$OOOOOO)),,
 .++-C"0"6"6"8 @JCKK&V 4uh?@ "3"9"9"; GJCKK-uF ;eXFGIIK / $ ! !s   A3D( (EE)r9   N)Fr   r   )NFNNN)FNNNr   )NFF)NNNNNNN)
 r  r  Nr  r  r  NNN)Fr@  )Yr  
__module____qualname____doc__r   rR   rn   r   propertyrV  r   rh   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   r>  rB  rE  r  rH  rJ  rL  r   r5  r`  r{  rf  r3   r   rl  rq  rv  r  _execute_queryr   r)   r  r  rT  r  r-  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$ / / /A3 A4 A ((//. .$ . 0. D  
 
4 
4 
4 
4 "hsm " " 
C 
D 
 
 #x} # # 
S 
T 
 
 7# 7 7 __	4c 	4d 	4 	4 F F FlB\%. J,4 ,d Id Ic Ic IRV I:0c 0d 0
 x/@ ( x}    $37".2R}R R $/0	R
 d^R N+R R 
tG}h'899	:Rl 37".2   $/0  d^	 
 N+    
x (+<"==	> 0Xd^ '
"$	4C 	4D 	4 59!
!.1!
	!
F(+<"= 44 4 
	4( 4$4 4 	4
 
%)>9:	;4 424$4 4 
	4"4$4 4 
	4"  ##-(-( d^-( 	-(
 -( -( 
%)>9:	;-( -(^ N $("#'59%)&*'+S4.S d^S 4.	S
 tL12S TNS smS  }S 
Sj '# ' ' ,s , , ,d , , )t ) ) +d + +).)	xUE\ 22	3)V& !%)-,0+/+ +  +  	+ 
 #+  +  +  +  "#+  %SM+  $C=+  
+ Zd   !'3 '84E+F ' "'(3- 4 44 4,# ,$ ,"8 ""( "" " " ""$" " 	"
 " 
"7T 7d 7 486:/ c3h0/ $DcN3/ 
	/r   r7   )Jr  rE   rM   ri   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   rp   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@   r   rX   <module>r     s   > . 	   
     3 > Q Q &  $    4	 	 	 K 2 GOc. c  

<SECs   
 C C#CC#