
    G)f~v             	         U d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	 ddl
mZm
Z
mZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z# dZ$	 ddl%Z% e&e%d      re%jN                  rdZ$ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; ddl<m=Z=m>Z>m?Z?m@Z@ e@rddlAmBZBmCZCmDZDmEZE ddlFmGZG ddlmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZO ddlPmQZQmRZR  ej                         ZTdeUd<   dZVdZWdZXdZYdZZee[ee
e\e]e^eef	Z_ G d deQ      Z` G d  d!e      Za G d" d#e      Zby# e($ r Y w xY w)$z+Module gathering all abstract base classes.    )annotationsN)ABCabstractmethod)datedatetimetime	timedelta)Decimal)	signature)sleep)TracebackType)AnyBinaryIOCallableDict	GeneratorIteratorListMappingNoReturnOptionalSequenceTupleTypeUnionFHAS_TLSv1_3T   )CONN_ATTRS_DNDEFAULT_CONFIGURATIONDEPRECATED_TLS_VERSIONSOPENSSL_CS_NAMESTLS_CIPHER_SUITESTLS_VERSIONSCharacterSet
ClientFlag)MySQLConverterMySQLConverterBase)DatabaseErrorErrorInterfaceErrorNotSupportedErrorOperationalErrorProgrammingError)CONNECTION_SPAN_NAMEOPTION_CNX_SPANOPTION_CNX_TRACEROTEL_ENABLED)end_spanrecord_exception_eventset_connection_span_attrstrace)read_option_files)BinaryProtocolTypeDescriptionTypeHandShakeTypeMySQLConvertibleTypeRowItemTypeRowType
StrOrBytesWarningType)GenericWrapperimport_objectz%weakref.WeakValueDictionary[Any, Any]NAMED_TUPLE_CACHEzVThe '{list}' list must not contain repeated values, the value '{value}' is duplicated.zdThe given tls_version: '{}' is not recognized as a valid TLS protocol version (should be one of {}).zHThe given tls_version: '{}' are no longer allowed (should be one of {}).zINo supported TLS protocol version found in the 'tls-versions' list '{}'. a  Option "krb_service_principal" {error}, must be a string in the form "primary/instance@realm" e.g "ldap/ldapauth@MYSQL.COM" where "@realm" is optional and if it is not given will be assumed to belong to the default realm, as configured in the krb5.conf file.c                      e Zd ZdZy)CMySQLPrepStmtaP  Structure to represent a result from `CMySQLConnection.cmd_stmt_prepare`.
    It can be used consistently as a type hint.

    `_mysql_connector.MySQLPrepStmt` isn't available when the C-ext isn't built.

    In this regard, `CmdStmtPrepareResult` acts as a proxy/wrapper entity for a
    `_mysql_connector.MySQLPrepStmt` instance.
    N)__name__
__module____qualname____doc__     V/var/www/html/flask-app/venv/lib/python3.12/site-packages/mysql/connector/abstracts.pyrC   rC      s    rI   rC   c                  v   e Zd ZU dZd\dZd]dZ	 	 	 	 	 	 	 	 d^dZd]dZed_d       Z	ed_d       Z
ed`d       Zdad	Zdbd
Zd\dZd\dZd\dZedcd       Zedcd       Zeddd       Zeded       Zeedcd              Zej.                  dfd       Zed_d       Zej.                  dgd       Zedhd       Zej.                  did       ZdjdZd\dZe	 dk	 	 	 	 	 	 	 dld       Zedmd       ZdndZdedZ eed_d              Z!dodZ"dpd Z#dqd!Z$edcd"       Z%e%j.                  dfd#       Z%edcd$       Z&e&j.                  drd%       Z&edsd&       Z'	 dt	 	 	 	 	 dud(Z(dvdgd)Z)ed_d*       Z*e*j.                  dgd+       Z*ed_d,       Z+e+j.                  dgd-       Z+ed_d.       Z,e,j.                  dgd/       Z,ed_d0       Z-e-j.                  dgd1       Z-edcd2       Z.edcd3       Z/	 dt	 	 	 	 	 dwd4Z0edcd5       Z1eedxd6              Z2ed\d7       Z3ed\d8       Z4d\d9Z5ed\d:       Z6e6Z7d;e8d<<   djd=Z9dydzd>Z:ed_d?       Z;ed{d|d@       Z<ed\dA       Z=e	 	 	 	 	 	 d}	 	 	 	 	 	 	 	 	 	 	 	 	 d~dB       Z>eddC       Z?ed\dD       Z@	 	 	 d	 	 	 	 	 	 	 ddEZA	 	 dt	 	 	 	 	 ddFZBddGZCe	 	 	 	 d	 	 	 	 	 	 	 	 	 ddH       ZDe	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 ddI       ZEeddJ       ZFe	 	 	 d	 	 	 	 	 	 	 	 	 ddK       ZGe	 	 	 	 ddL       ZHeddM       ZIeddN       ZJedddO       ZKeddP       ZLedpdQ       ZMeddR       ZNeddS       ZOeddT       ZPe	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddU       ZQe	 	 	 	 ddV       ZRe	 	 	 d	 	 	 	 	 	 	 	 	 ddW       ZSeddX       ZTe	 	 	 	 	 	 	 	 ddY       ZUeddZ       ZVed_d[       ZWy')MySQLConnectionAbstractz8Abstract class for classes connecting to a MySQL server.c                d   d| _         d| _        d| _        t        j                         | _        d| _        d| _        d| _        d| _	        d| _
        d| _        i | _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        i | _        t2        d	   | _        d| _        d| _        d| _        d| _        d| _        d| _         d| _!        d| _"        d| _#        t2        d
   | _$        d| _%        d| _&        d| _'        d| _(        d| _)        t2        d   | _*        t2        d   | _+        d| _,        i | _-        d| _.        d| _/        d| _0        d| _1        d| _2        d| _3        d| _4        d| _5        d| _6        d| _7        tq               | _9        y)
InitializeNT-   F z	127.0.0.1i  r   ssl_disabledconnect_timeoutallow_local_infileallow_local_infile_in_path):_tracer_spanotel_context_propagationr%   get_default_client_flags_charset_id	_sql_mode
_time_zone_autocommit_server_version
_handshake_conn_attrs_user	_password
_password1
_password2
_password3	_database_host_port_unix_socket_client_host_client_port_sslr   _ssl_disabled_force_ipv6_oci_config_file_oci_config_profile_fido_callback_webauthn_callback_krb_service_principal_use_unicode_get_warnings_raise_on_warnings_connection_timeout	_buffered_unread_result_have_next_result_raw_in_transaction_allow_local_infile_allow_local_infile_in_path_prepared_statements_query_attrs_ssl_active_auth_plugin_auth_plugin_class_pool_config_version	converter_converter_class_converter_str_fallback	_compress_consume_results_init_commandr$   _character_setselfs    rJ   __init__z MySQLConnectionAbstract.__init__   s    !
.2%","8"8": "(,)-!&:>37+-
 !!! %

+/!#!"FH	#8#H!&/326 KOOS59#"&#((-2G3
   %$)',	%*)>?S)T :O(;
( *.!;=!&+/15)-!37@D-2$$&+,0,8NrI   c                    | S NrH   r   s    rJ   	__enter__z!MySQLConnectionAbstract.__enter__       rI   c                $    | j                          y r   closer   exc_type	exc_value	tracebacks       rJ   __exit__z MySQLConnectionAbstract.__exit__        	

rI   c                    | S )zReturns self for `weakref.proxy`.

        This method is used when the original object is needed when using
        `weakref.proxy`.
        rH   r   s    rJ   get_selfz MySQLConnectionAbstract.get_self   s	     rI   c                d    | j                   xs# | j                  duxr t        j                  dk(  S )z)Returns `True` if is a secure connection.Nposix)r   ri   osnamer   s    rJ   	is_securez!MySQLConnectionAbstract.is_secure  s3      
T)@bgg.@	
rI   c                    | j                   S )zReturns If have next result.)rz   r   s    rJ   have_next_resultz(MySQLConnectionAbstract.have_next_result  s     %%%rI   c                H    t        | j                  j                               S )zReturns query attributes list.)listr   itemsr   s    rJ   query_attrsz#MySQLConnectionAbstract.query_attrs  s     D%%++-..rI   c                J    |\  }}|| j                   vr|| j                   |<   yy)a  Adds element to the query attributes list on the connector's side.

        If an element in the query attributes list already matches
        the attribute name provided, the new element will NOT be added.

        Args:
            value: key-value as a 2-tuple.
        Nr   )r   value	attr_name
attr_values       rJ   query_attrs_appendz*MySQLConnectionAbstract.query_attrs_append  s1     !&	:D---+5Di( .rI   c                :    | j                   j                  |d      S )zRemoves element by name from the query attributes list on the connector's side.

        If no match, `None` is returned, else the corresponding value is returned.

        Args:
            name: key name.
        N)r   popr   r   s     rJ   query_attrs_removez*MySQLConnectionAbstract.query_attrs_remove#  s       $$T400rI   c                    i | _         y)z5Clears query attributes list on the connector's side.Nr   r   s    rJ   query_attrs_clearz)MySQLConnectionAbstract.query_attrs_clear-  s
    rI   c                4   g }| j                   d   }t        |t              r|j                  d      r|j	                  d      st        d| d      |dd j                  d      }|st        d	      |D ]4  }|j                         j                         }|s$|j                  |       6 n8t        |t        t        f      r|D cg c]  }|s|	 }}nt        d
| d      | j                   j                  dd      	t        dd n| j                   d   dd }|j                  d       |d   }g g g}i }g }	t        dt        j                  |      dz    D ]2  }
|j!                  t"        |
          |	j%                  t&        |
          4 |D ]  }d|v r9||	v r5|t&        d   v r|d   j                  |       +|d   j                  |       @||v rd||   }||v r t        t(        j+                  d|            |t"        d   v r|d   j                  ||          |d   j                  ||          t        d| d       |d   s|d   st        d      dj-                  |d         dj-                  |d         g| j                   d<   yc c}w )z&Validates the tls_ciphersuites option.tls_ciphersuites[]z)tls_ciphersuites must be a list, found: ''r   ,z6No valid cipher suite found in 'tls_ciphersuites' listzItls_ciphersuites should be a list with one or more ciphersuites. Found: 'tls_versionsNT)reverser   -TLSv1.3r   r   zThe value 'z1' in tls_ciphersuites is not a valid cipher suitez:No valid cipher suite found in the 'tls_ciphersuites' list:)rl   
isinstancestr
startswithendswithAttributeErrorsplitstripupperappendr   setgetr#   sortindexupdater"   extendr!   DUPLICATED_IN_LIST_ERRORformatjoin)r   r   tls_cstls_css_tls_csr   newer_tls_vertranslated_namesiani_cipher_suites_namesossl_cipher_suites_namestls_verr   translated_names                rJ   _validate_tls_ciphersuitesz2MySQLConnectionAbstract._validate_tls_ciphersuites1  s
   -.fc"%%c*vs/C$?xqI  Qrl((-G$L  # 5 ,,...0$++G45
 s,5;F6vFF ))/3  yy}}^T2: O>*1- 	 	$'$Q .0H#% .0  $$Kl&8&8&G!&KL 	GG$++,=g,FG$++,<W,EF	G % 	Dd{t'??+I66$Q'..t4$Q'..t411":4"@"&66(077!3? 8  
 ,Y77$Q'../G/MN$Q'../G/MN$!$ (# # '	.  "+;A+> L 
 HH%a()HH%a())
		$%s  Gs   JJc                   g }| j                   d   }t        |t              r|j                  d      r|j	                  d      st        d| d      |dd j                  d      }|D ]M  }|j                         }|d	k(  r||v r t        t        j                  d|
            |j                  |       O |dgk(  rt        st        t        j                  |t                    t        |t              rJ|st        d      |D ]7  }||v r t        t        j                  d|
            |j                  |       9 nNt        |t              r|D ]  }|j                  |        n%t        ddj!                  t               d| d      |st        d      g }g }g }|D ]F  }|t        v r|j                  |       |t"        v r|j                  |       6|j                  |       H |rO|dgk(  r)t        s#t%        t        j                  |t                    |j'                          || j                   d<   y|r#t%        t(        j                  |t                    |r#t        t*        j                  t                    y)z"Validates the tls_versions option.r   r   r   z%tls_versions must be a list, found: 'r   r   r   r   rP   r   r   zJAt least one TLS protocol version must be specified in 'tls_versions' listz>tls_versions should be a list with one or more of versions in z, z
. found: 'zdAt least one TLS protocol version must be specified in 'tls_versions' list when this option is givenN)rl   r   r   r   r   r   r   r   r   r   r   TLS_V1_3_SUPPORTEDTLS_VER_NO_SUPPORTEDr#   r   r   r   r    r+   r   TLS_VERSION_DEPRECATED_ERRORTLS_VERSION_ERROR)r   r   tls_versiontls_versr   use_tls_versionsdeprecated_tls_versionsinvalid_tls_versionss           rJ   _validate_tls_versionsz.MySQLConnectionAbstract._validate_tls_versions  s   ii/k3'**3/K4H4H4M$;K=J  #1R(..s3H# 
1%mmo"$,.(077!/{ 8  
 ##K0
1 I;&/A$(//\J  T*$*  ' -l*(077!/w 8  
 ##G,- S)& -##G,- !ii-.jaI 
  C 
 "$!# 	5G,& ''011'..w7$++G4	5 I;.7I'(//\J  !!#(8DIIn%$#,33+\ 
 " !2!9!9'<!PQQ "rI   c                    | j                   S )z6The user name used for connecting to the MySQL server.)ra   r   s    rJ   userzMySQLConnectionAbstract.user       zzrI   c                    | j                   S )z MySQL server IP address or name.)rg   r   s    rJ   server_hostz#MySQLConnectionAbstract.server_host  r   rI   c                    | j                   S )zMySQL server TCP/IP port.)rh   r   s    rJ   server_portz#MySQLConnectionAbstract.server_port  r   rI   c                    | j                   S )z8The Unix socket file for connecting to the MySQL server.)ri   r   s    rJ   unix_socketz#MySQLConnectionAbstract.unix_socket  s        rI   c                     y)zThe current database.NrH   r   s    rJ   databasez MySQLConnectionAbstract.database      rI   c                ,    | j                  d|        y)zSets the current database.zUSE N)	cmd_queryr   r   s     rJ   r   z MySQLConnectionAbstract.database  s     	eW~&rI   c                    | j                   S )z#Returns whether to consume results.)r   r   s    rJ   can_consume_resultsz+MySQLConnectionAbstract.can_consume_results  s     $$$rI   c                6    t        |t              sJ || _        y)zSets if can consume results.N)r   boolr   r   s     rJ   r   z+MySQLConnectionAbstract.can_consume_results  s     %&& %rI   c                    | j                   S )z'Returns the pool configuration version.r   r   s    rJ   pool_config_versionz+MySQLConnectionAbstract.pool_config_version  s     (((rI   c                    || _         y)z#Sets the pool configuration versionNr   r   s     rJ   r   z+MySQLConnectionAbstract.pool_config_version  s     %*!rI   c                0   |j                  t        d      | _        |j                  t        d      | _        |j                         }d|v rt        d      t        dOi |}	 |d   | _        |d= 	 |d   | _
        |d= 	 t        j                         }| j                  |d   xs |       |d= 	 |d   r'd| _        | j                  t        j                  g       |j!                  d	t"        d	         | _        |j!                  d
t"        d
         | _        d}| j&                  rt(        j*                  j-                  | j&                        }|r>t(        j*                  j/                  |      rt(        j*                  j1                  |      rt(        j*                  j3                  |      rt5        d      | j$                  s| j&                  r!| j                  t        j6                  g       n!| j                  t        j6                   g       	 |d   sd| _        nd| _        	 |d   | _        |d= | j:                  dk(  rt=        d| j:                   d      	 | j?                  |d          g d}|D ]  \  }}	 ||vr||   ||<   ||=  d|v sd|v r$	 |d   }	|d= 	 |d   }
|d= | jG                  |	|
       d|v r|d   r
|d   | _$        	 tK        |d         | _&        |d= d|v r|j                  d      | _(        d|v r|d   | _)        |d= d}|jU                         D ]  \  }}	 t"        |    |jW                  d      r0d}| jX                  j[                  |j]                  dd      |i       Q|jW                  d      r d}| jX                  j[                  ||i       d |z   }	 t_        | ||ja                                 | jb                  rt(        jd                  d!k(  rd| _(        | jP                  r| j:                  d"k(  rt=        d#      |rvd$| jX                  vrt"        d%   | jX                  d$<   d&| jX                  vrt"        d'   | jX                  d&<   d(| jX                  vs| jX                  d(   d| jX                  d(<   tg        d)| jX                  v       tg        d*| jX                  v       k7  rt5        d+      ti        d,      ti        | jX                        k  sd| jX                  d)<   d| jX                  d*<   n.| jX                  d)   du | jX                  d*   du k7  rt5        d-      d.| jX                  v r| jX                  d.   | jk                          d/| jX                  v r| jX                  d/   | jm                          | jn                  i | _7        ntq        | jn                  tr              st=        d0      | jn                  jU                         D ]  \  }}|tt        v rtq        |tv              st=        d1| d2| jn                   d      ty        |      d3kD  rt=        d4| d5      |jW                  d       rt=        d6      tq        |tv              st=        d7| d8| d9      ty        |      d:kD  st=        d7| d8| d;       | jz                  t        j|                  z  r| j                          d<|v ry|d<   ttq        |d<   tv              st=        d=      |d<   j                         }|d>k(  r&t(        jd                  d?k7  rt=        d@      dA| _A        n|dBk(  rdC| _A        nt=        dD      dE|v r|dE   |dE   | _B        tq        | j                  tv              st=        t        j                  dFG            | j                  dk(  rt=        t        j                  dHG            dI| j                  vrt=        t        j                  dJG            | j                  r9dK}t        j                  |t               | j                  dL| j                  dM       | j                  r| j                  dN| j                  dM       yy# t        $ r Y w xY w# t        $ r Y w xY w# t        $ r Y w xY w# t        $ r Y w xY w# t        $ r d| _        Y w xY w# t        $ r d| _        Y w xY w# t        $ r Y at@        $ r}t5        d      |d}~ww xY w# t        $ r Y w xY w# t        $ r | jB                  }	Y vw xY w# t        $ r | jD                  }
Y w xY w# t        $ r Y ]tN        $ r}t=        d      |d}~ww xY w# t        $ r t5        d| d      dw xY w# t4        $ r t_        | ||       Y rw xY w)Pa  Configures the MySQL Connection.

        This method allows you to configure the `MySQLConnection`
        instance after it has been instantiated.

        Args:
            **kwargs: For a complete list of possible arguments, see [1].

        Raises:
            AttributeError: When provided unsupported connection arguments.
            InterfaceError: When the provided connection argument is invalid.

        References:
            [1]: https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html
        Ndsnz!Data source name is not supportedget_warningsraise_on_warningsclient_flagscompressTrS   rT   z.allow_local_infile_in_path must be a directoryconsume_resultsFauth_pluginrP   authentication_webauthn_clientr   z5' cannot be used as the default authentication pluginconverter_classzEConverter class should be a subclass of conversion.MySQLConverterBase))dbr   )usernamer   )passwdpassword)rR   connection_timeout)read_default_fileoption_filesr   r  hostportz'TCP/IP port number should be an integerrQ   init_commandzUnsupported argument 'ssl_tls__r   mysql_clear_passwordzEClear password authentication is not supported over insecure channelsverify_certssl_verify_certverify_identityssl_verify_identitycakeycertz:ssl_key and ssl_cert need to be both specified, or neither)r  r  z4ssl_key and ssl_cert need to be both set, or neitherr   r   zconn_attrs must be of type dictz+Attribute name should be a string, found: 'z' in '    zAttribute name 'z"' exceeds 32 characters limit sizezNKey names in connection attributes cannot start with '_', found: '{attr_name}'zAttribute 'z
' value: 'z' must be a string typei   z$' exceeds 1024 characters limit sizekerberos_auth_modez('kerberos_auth_mode' must be of type strsspintz6'kerberos_auth_mode=SSPI' is only available on WindowsMySQLSSPIKerberosAuthPlugingssapiMySQLKerberosAuthPluginz@Invalid 'kerberos_auth_mode' mode. Please use 'SSPI' or 'GSSAPI'krb_service_principalzis not a string)errorzcan not be an empty string/zis incorrectly formattedzThe `fido_callback` connection argument is deprecated and it will be removed in a future release of MySQL Connector/Python. Use `webauth_callback` insteadfido_callbackr   webauth_callbackrH   )Kr   r/   rV   r0   rU   copyr+   r6   r  KeyErrorr  r%   rX   set_client_flagsr   COMPRESSr   r   r}   r~   r   pathabspathexistsisdirislinkr   LOCAL_FILESr   r   r*   set_converter_class	TypeErrorra   rb   	set_loginrg   intrh   
ValueErrorrm   r   r   r   rl   r   replacesetattrr   ri   r   r   r   r   r   r`   r   dictr   r   lenrY   CONNECT_ARGS_add_default_conn_attrslowerr   rs   KRB_SERVICE_PINCIPAL_ERRORr   rq   warningswarnDeprecationWarning_validate_callablerr   )r   kwargsconfigdefaultinfile_in_patherr
compat_mapcompat	translater   r  set_ssl_flagr  r   	attributer   r   r   warn_msgs                      rJ   rG  zMySQLConnectionAbstract.config	  s
   " ZZ6
zz"3T:F?#$GHH #,V,	 &~ 6D~&	%+,?%@D"*+
	 ,,.G!!&"8"CGD~&	j!!%%%z':':&;< $*:: "78L"M$
  ,2::(!">?,
( ++WW__T-M-MNNGGNN>2n577>>.1$%UVV##t'G'G!!:#9#9":;!!J$:$:#:";<	*+,(-%(,%
	# &} 5D}%
  @@ D%%& '  	$$V,=%>?

 ", 	FIF*(.vF9%6N		 VzV3"f~6N*!*-:& NN4* VvDJ	UVF^,DJv V#!'N!;D V#!'!7D~&  ,,. 	4JCP%c* ~~f%#		  #++fb"95!AB'#		  #u.#I	4D)U[[];	4( G!3!%D$"3"37M"M W  DII-+@AR+S		-( 		1/D)0		+, 499$		$(?"$		$ETYY&'4$))0C+DD$P  '3tyy>9#'		% $(		&!))E"d*		&0AT0IJ$J  *tyy/H/T++- #dii/II01=//1#!DD,,d3 !BCC)-)9)9)?)?)A %	:-!)S1(%;fT-=-=,>aA 
 y>B&(*9+5WX  '',(4 
 "*c2(%i[
:, G+ + 
 z?T)(%i[
:, G= = 9B 
 7 77((*6)f5I.J.Vf%9:C@$%OPP!'(<!=!C!C!E!V+77d?(P  +H'#x/*C'$V 
 $v-./;*01H*ID'd993?$.55<M5N  **b0$.55: 6  
 $555$.55<V5W  1 
 MM($67##OT5H5H!L""##$68O8OQRS #m  		
  		  		  		<  	*$)D!	*  	# "D	#  	 	 0 	(    "zz"
  *>>*  	 	U !JKQTT	U   P$'=cU!%DE4OP & 4D)U34s   "a 0a( >/a8 .,b b 'b/ c >c.c> !d d6 )	e*e;	a%$a%(	a54a58	bb	bbb,+b,/cc	c+c+c&&c+.	c;:c;>ddd32d36	ee
eee8;ffc                     y)z'Adds the default connection attributes.NrH   r   s    rJ   r?  z/MySQLConnectionAbstract._add_default_conn_attrsA  r   rI   c                   t        |t              r	 t        |      }t        |      st	        d|  d      t        t        |      j                        }||k7  rt	        d|  d| d|       y# t        $ r}t	        |       |d}~ww xY w)a  Validates if it's a Python callable.

         Args:
             option_name (str): Connection option name.
             callback (str or callable): The fully qualified path to the callable or
                                         a callable.
             num_args (int): Number of positional arguments allowed.

        Raises:
             ProgrammingError: If `callback` is not valid or wrong number of positional
                               arguments.

        .. versionadded:: 8.2.0
        NzExpected a callable for 'r   z' requires z4 positional argument, but the callback provided has )	r   r   r@   r9  r-   callabler=  r   
parameters)option_namecallbacknum_argsrJ  
num_paramss        rJ   rE  z*MySQLConnectionAbstract._validate_callableD  s    $ h$:(2 !"%>{m1#MNN 8,778
!"K=H: 6))36  "  :&#0c9:s   A/ /	B
8BB
c                &   t        | t        t        f      r| j                         } t	        j
                  d      }|j                  |       }|st        d      t        d |j                         dd D              }|dk  rt        d|  d      |S )	a9  Checks the MySQL version.

        This method will check the MySQL version and raise an InterfaceError
        when it is not supported or invalid. It will return the version
        as a tuple with major, minor and patch.

        Raises InterfaceError if invalid server version.

        Returns tuple
        z$^(\d{1,2})\.(\d{1,2})\.(\d{1,3})(.*)zFailed parsing MySQL versionc              3  2   K   | ]  }t        |        y wr   )r8  ).0vs     rJ   	<genexpr>z@MySQLConnectionAbstract._check_server_version.<locals>.<genexpr>{  s     <1A<s   r      )   r   zMySQL Version 'z' is not supported)
r   	bytearraybytesdecoderecompilematchr*   tuplegroups)server_version	regex_verre  versions       rJ   _check_server_versionz-MySQLConnectionAbstract._check_server_versiong  s     ny%&89+224NJJFG	/ !?@@<q(;<<V ?>2BBT!UVVrI   c                    | j                   S )zGets the MySQL version.

        Returns:
            The MySQL server version as a tuple. If not previously connected, it will
            return `None`.
        )r^   r   s    rJ   get_server_versionz*MySQLConnectionAbstract.get_server_version  s     ###rI   c                L    	 | j                   d   S # t        t        f$ r Y yw xY w)zGets the original MySQL version information.

        Returns:
            The original MySQL server as text. If not previously connected, it will
            return `None`.
        server_version_originalN)r_   r6  r,  r   s    rJ   get_server_infoz'MySQLConnectionAbstract.get_server_info  s.    	??#<==8$ 		s    ##c                     y)aM  Returns bool to indicate whether a transaction is active for the connection.

        The value is `True` regardless of whether you start a transaction using the
        `start_transaction()` API call or by directly executing an SQL statement such
        as START TRANSACTION or BEGIN.

        `in_transaction` was added in MySQL Connector/Python 1.1.0.

        Examples:
            ```
            >>> cnx.start_transaction()
            >>> cnx.in_transaction
            True
            >>> cnx.commit()
            >>> cnx.in_transaction
            False
            ```
        NrH   r   s    rJ   in_transactionz&MySQLConnectionAbstract.in_transaction  r   rI   c                .   t        |t              r|dkD  r|| _        | j                  S t        |t        t        f      rM|D ]<  }|dk  r | xj                  t        |       z  c_        (| xj                  |z  c_        > | j                  S t        d      )a  Sets the client flags.

        The flags-argument can be either an int or a list (or tuple) of
        ClientFlag-values. If it is an integer, it will set client_flags
        to flags as is.

        If flags is a sequence, each item in the sequence sets the flag when the
        value is positive or unsets it when negative (see example below).

        Args:
            flags: A list (or tuple), each flag will be set or unset when it's negative.

        Returns:
            integer: Client flags.

        Raises:
            ProgrammingError: When the flags argument is not a set or an integer
                              bigger than 0.

        Examples:
            ```
            For example, to unset `LONG_FLAG` and set the `FOUND_ROWS` flags:
            >>> from mysql.connector.constants import ClientFlag
            >>> cnx.set_client_flags([ClientFlag.FOUND_ROWS, -ClientFlag.LONG_FLAG])
            >>> cnx.reconnect()
            ```
        r   z+set_client_flags expect integer (>0) or set)r   r8  rY   rf  r   absr-   )r   flagsflags      rJ   r-  z(MySQLConnectionAbstract.set_client_flags  s    8 eS!eai!&D !!! t}- /!8&&3t9*4&&&$.&	/ !!! ##PQQrI   c                    t         )ak  Shuts down connection to MySQL Server.

        This method closes the socket. It raises no exceptions.

        Unlike `disconnect()`, `shutdown()` closes the client connection without
        attempting to send a `QUIT` command to the server first. Thus, it will not
        block if the connection is disrupted for some reason such as network failure.
        )NotImplementedErrorr   s    rJ   shutdownz MySQLConnectionAbstract.shutdown  s
     "!rI   c                &    | j                   |z  dkD  S )z|Checks if a client flag is set.

        Returns:
            `True` if the client flag was set, `False` otherwise.
        r   )rY   )r   rv  s     rJ   isset_client_flagz)MySQLConnectionAbstract.isset_client_flag  s     ""T)Q..rI   c                *    | j                  d      d   S )zGets the current time zone.zSELECT @@session.time_zoner   
info_queryr   s    rJ   	time_zonez!MySQLConnectionAbstract.time_zone  s     ;<
 	
rI   c                <    | j                  d| d       || _        y)zSets the time zone.zSET @@session.time_zone = 'r   N)r   r\   r   s     rJ   r  z!MySQLConnectionAbstract.time_zone  s!     	4UG1=>rI   c                d    | j                   | j                  d      d   | _         | j                   S )zGets the SQL mode.zSELECT @@session.sql_moder   )r[   r~  r   s    rJ   sql_modez MySQLConnectionAbstract.sql_mode  s.     >>!!__-HI!LDN~~rI   c                    t        |t        t        f      rdj                  |      }| j	                  d| d       || _        y)a  Sets the SQL mode.

        This method sets the SQL Mode for the current connection. The value
        argument can be either a string with comma separate mode names, or
        a sequence of mode names.

        It is good practice to use the constants class `SQLMode`:
        ```
        >>> from mysql.connector.constants import SQLMode
        >>> cnx.sql_mode = [SQLMode.NO_ZERO_DATE, SQLMode.REAL_AS_FLOAT]
        ```
        r   zSET @@session.sql_mode = 'r   N)r   r   rf  r   r   r[   r   s     rJ   r  z MySQLConnectionAbstract.sql_mode  s<     edE]+HHUOE3E7!<=rI   c                     y)a9  Sends a query which only returns 1 row.

        Shortcut for:

        ```
        cursor = self.cursor(buffered=True)
        cursor.execute(query)
        return cursor.fetchone()
        ```

        Args:
            query: Statement to execute.

        Returns:
            row: A tuple (RowType).
        NrH   r   querys     rJ   r~  z"MySQLConnectionAbstract.info_query  r   rI   Nc                d    ||j                         | _        nd| _        ||| _        yd| _        y)zSets login information for MySQL.

        Sets the username and/or password for the user connecting to the MySQL Server.

        Args:
            username: Account's user name.
            password: Account's password.
        NrP   )r   ra   rb   )r   r  r  s      rJ   r7  z!MySQLConnectionAbstract.set_login!  s3     !)DJDJ%DNDNrI   c                b    || _         | j                  r| j                  j                  |       yy)zToggles unicode mode.

        Sets whether we return string fields as unicode or not.

        Args:
            value: A boolean - default is `True`.
        N)rt   r   set_unicoder   s     rJ   r  z#MySQLConnectionAbstract.set_unicode5  s*     ">>NN&&u- rI   c                4    | j                  d      d   }|dk(  S )z%Gets whether autocommit is on or off.zSELECT @@session.autocommitr   r   r}  r   s     rJ   
autocommitz"MySQLConnectionAbstract.autocommitA  s"      =>qAzrI   c                F    |rdnd}| j                  d|        || _        y)zToggles autocommit.ONOFFzSET @@session.autocommit = N)r   r]   )r   r   switchs      rJ   r  z"MySQLConnectionAbstract.autocommitG  s)     E4VH=> rI   c                    | j                   S )zGets whether this connection retrieves warnings automatically.

        This method returns whether this connection retrieves warnings
        automatically.

        Returns `True`, or `False` when warnings are not retrieved.
        )ru   r   s    rJ   r  z$MySQLConnectionAbstract.get_warningsN  s     !!!rI   c                H    t        |t              st        d      || _        y)zSets whether warnings should be automatically retrieved.

        The toggle-argument must be a boolean. When True, cursors for this
        connection will retrieve information about warnings (if any).

        Raises `ValueError` on error.
        Expected a boolean typeN)r   r   r9  ru   r   s     rJ   r  z$MySQLConnectionAbstract.get_warningsY  s"     %&677"rI   c                    | j                   S )zGets whether this connection raises an error on warnings.

        This method returns whether this connection will raise errors when
        MySQL reports warnings.

        Returns `True` or `False`.
        )rv   r   s    rJ   r  z)MySQLConnectionAbstract.raise_on_warningsf  s     &&&rI   c                \    t        |t              st        d      || _        |r|| _        yy)a  Sets whether warnings raise an error.

        The toggle-argument must be a boolean. When True, cursors for this
        connection will raise an error when MySQL reports warnings.

        Raising on warnings implies retrieving warnings automatically. In
        other words: warnings will be set to True. If set to False, warnings
        will be also set to False.

        Raises `ValueError` on error.
        r  N)r   r   r9  rv   ru   r   s     rJ   r  z)MySQLConnectionAbstract.raise_on_warningsq  s2     %&677"'!&D rI   c                    | j                   S )zGets whether there is an unread result.

        This method is used by cursors to check whether another cursor still
        needs to retrieve its result set.

        Returns `True`, or `False` when there is no unread result.
        )ry   r   s    rJ   unread_resultz%MySQLConnectionAbstract.unread_result       """rI   c                H    t        |t              st        d      || _        y)zSets whether there is an unread result.

        This method is used by cursors to let other cursors know there is
        still a result set that needs to be retrieved.

        Raises `ValueError` on errors.
        r  N)r   r   r9  ry   r   s     rJ   r  z%MySQLConnectionAbstract.unread_result  s"     %&677#rI   c                R    | j                   j                  | j                        d   S )a,  Returns the character set for current connection.

        This property returns the character set name of the current connection.
        The server is queried when the connection is active. If not connected,
        the configured character set name is returned.

        Returns a string.
        r   r   get_inforZ   r   s    rJ   charsetzMySQLConnectionAbstract.charset  s&     ""++D,<,<=a@@rI   c                `    | j                   j                  | j                        d   }|dv ry|S )az  Returns the Python character set for current connection.

        This property returns the character set name of the current connection.
        Note that, unlike property charset, this checks if the previously set
        character set is supported by Python and if not, it returns the
        equivalent character set that Python supports.

        Returns a string.
        r   )utf8mb4utf8mb3binaryutf8r  )r   encodings     rJ   python_charsetz&MySQLConnectionAbstract.python_charset  s6     &&//0@0@A!D77rI   c                <   d}t        |t        t        f      s|t        |j	                  d            t        |t              s|t        d      |rt        |t              r%| j
                  j                  |      \  | _        }}nt        |t              r&| j
                  j                  ||      \  | _        }}nqt        |j	                  d            |r&| j
                  j                  |      \  | _        }}n/t        d   }| j
                  j                  |d      \  | _        }}| j                  d| d| d       	 | j                  |       | j                  r(| j                  j                  || j
                  	       yy# t        $ r Y @w xY w)
a  Sets the character set and collation for the current connection.

        This method sets the character set and collation to be used for
        the current connection. The charset argument can be either the
        name of a character set as a string, or the numerical equivalent
        as defined in constants.CharacterSet.

        When the collation is not given, the default will be looked up and
        used.

        Args:
            charset: Can be either the name of a character set, or the numerical
                     equivalent as defined in `constants.CharacterSet`.
            collation: When collation is `None`, the default collation for the
                       character set is used.

        Examples:
            The following will set the collation for the latin1 character set to
            `latin1_general_ci`:
            ```
            >>> cnx = mysql.connector.connect(user='scott')
            >>> cnx.set_charset_collation('latin1', 'latin1_general_ci')
            ```
        z+{} should be either integer, string or NoneNr  z)collation should be either string or None)	collationzSET NAMES 'z' COLLATE 'r   )character_set)r   r8  r   r9  r   r   get_charset_inforZ   r   _execute_queryset_character_set_namer   r   set_charset)r   r  r  err_msgcharset_namecollation_names         rJ   set_charset_collationz-MySQLConnectionAbstract.set_charset_collation  s   6 @'C:.73FW^^I677)S)i.CHII'3'
 ''88A	$ "GS)
 ''88)L	$ " !	!:;;
 ##44y4I	  ,I6G
 ##44W4M	  	k,{>BRRSTU	''5
 >>NN&&|4CVCV&W 	  		s   	F 	FFc                R    | j                   j                  | j                        d   S )a   Returns the collation for current connection.

        This property returns the collation name of the current connection.
        The server is queried when the connection is active. If not connected,
        the configured collation name is returned.

        Returns a string.
           )r   r  rZ   r   s    rJ   r  z!MySQLConnectionAbstract.collation  s&     ""33D4D4DEaHHrI   c                     y)zMySQL connection ID.NrH   r   s    rJ   connection_idz%MySQLConnectionAbstract.connection_id  r   rI   c                     y)z>Gathers information of the MySQL server before authentication.NrH   r   s    rJ   _do_handshakez%MySQLConnectionAbstract._do_handshake  r   rI   c                     y)z)Opens the connection to the MySQL server.NrH   r   s    rJ   _open_connectionz(MySQLConnectionAbstract._open_connection  r   rI   c                    | j                  | j                         | j                  | _        | j                  r| j                  | _        | j                  r| j                  | _        | j                  r| j                  | j                         yy)zExecutes commands after connection has been established.

        This method executes commands after the connection has been
        established. Some setting like autocommit, character set, and SQL mode
        are set using this method.
        N)
r  rZ   r]   r  r\   r  r[   r  r   r  r   s    rJ   _post_connectionz(MySQLConnectionAbstract._post_connection  sk     	""4#3#34**??!__DN>> NNDM 2 23 rI   c                     y)a  Disconnects from the MySQL server.

        This method tries to send a `QUIT` command and close the socket. It raises
        no exceptions.

        `MySQLConnection.close()` is a synonymous for `MySQLConnection.disconnect()`
        method name and more commonly used.

        To shut down the connection without sending a `QUIT` command first,
        use `shutdown()`.
        NrH   r   s    rJ   
disconnectz"MySQLConnectionAbstract.disconnect,  r   rI   zCallable[[], Any]r   c                l   |r | j                   d	i | | j                          | j                          |j                  dd      |j                  dd      }}|s|r$| j                  j                  ||      d   | _        | j                  t        j                  z  s| j                          y	 | j                  | j                         y# t        $ r] | j                  d| j                  xs | j                   d       | j                  | j                         | j                  d       Y yw xY w)
a  Connects to the MySQL server.

        This method sets up the connection to the MySQL server. If no
        arguments are given, it will use the already configured or default
        values.

        Args:
            **kwargs: For a complete list of possible arguments, see [1].

        Examples:
            ```
            >>> cnx = MySQLConnection(user='joe', database='test')
            ```

        References:
            [1]: https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html
        r  Nr  r   )r  zSET PASSWORD = 'r   z)ALTER USER CURRENT_USER() PASSWORD EXPIRErH   )rG  r  r  r   r   r  rZ   rY   r%   CAN_HANDLE_EXPIRED_PASSWORDSr  r  r(   r   rc   rb   )r   rF  r  r  s       rJ   connectzMySQLConnectionAbstract.connect<  s   & DKK!&! JJy$'JJ{D)  i#22CCGYW D !!J$K$KK!!#L**43C3C*D  	L !1$//2ST^^1TTUVW **43C3C*D JK	Ls   0C A#D32D3c                f   d}d}| j                   r9| j                   j                  t        t        j                  j
                        }	 ||k7  rN|dz   }	 | j                          | j                          | j                         rn	 |dkD  rt        |       ||k7  rN|| _        t        rt        | | j"                         yy# t        t        f$ r#}||k(  rd| d| }t        |      |Y d}~hd}~ww xY w# t        $ r/}t        r#t        | |       t        ||       t!        |        d}~ww xY w)a  Attempts to reconnect to the MySQL server.

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

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

        Args:
            attempts: Number of attempts to make when reconnecting.
            delay: Use it (defined in seconds) if you want to wait between each retry.

        Raises:
            InterfaceError: When reconnection fails.
        r   N)r   kindr   z!Can not reconnect to MySQL after z attempt(s): )rU   
start_spanr.   r5   SpanKindCLIENTr  r  is_connectedr)   IOErrorr*   r   r1   r4   r3   r2   rV   )r   attemptsdelaycounterspanrJ  msginterface_errs           rJ   	reconnectz!MySQLConnectionAbstract.reconnectr  s9   $ <<<<**)0E0E + D	X%!A+;OO%LLN((* + 19%L X%. 
%dDJJ7 # w' ;(*?z J++.%1  -S1s: +;  	)$5&t];	sB   
C8 0C C8 C5C0+C8 0C55C8 8	D0*D++D0c                     y)a  Reports whether the connection to MySQL Server is available or not.

        Checks whether the connection to MySQL is available using the `ping()` method,
        but unlike `ping()`, `is_connected()` returns `True` when the connection is
        available, `False` otherwise
        NrH   r   s    rJ   r  z$MySQLConnectionAbstract.is_connected  r   rI   c                     y)a  Checks 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.

        Args:
            reconnect: If True, one or more `attempts` are made to try to reconnect
                       to the MySQL server, and these options are forwarded to the
                       `reconnect()` method.
            attempts: Number of attempts to make when reconnecting.
            delay: Use it (defined in seconds) if you want to wait between each retry.

        Raises:
            InterfaceError: When the connection is not available. Use the
                            `is_connected()` method if you just want to check the
                            connection without raising an error.
        NrH   )r   r  r  r  s       rJ   pingzMySQLConnectionAbstract.ping  r   rI   c                     y)a  Commits current transaction.

        This method is part of PEP 249 - Python Database API Specification v2.0.

        This method sends a COMMIT statement to the MySQL server, committing the
        current transaction. Since by default Connector/Python does not autocommit.

        It is important to call this method after every transaction that modifies
        data for tables that use transactional storage engines.

        Examples:
            ```
            >>> stmt = "INSERT INTO employees (first_name) VALUES (%s), (%s)"
            >>> cursor.execute(stmt, ('Jane', 'Mary'))
            >>> cnx.commit()
            ```
        NrH   r   s    rJ   commitzMySQLConnectionAbstract.commit  r   rI   c                     y)a  Instantiates and returns a cursor.

        By default, `MySQLCursor` or `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.CursorBase`
        or `mysql.connector.cursor_cext.CMySQLCursor` according to the type of
        connection that's being used.

        Args:
            buffered: If `True`, the cursor fetches all rows from the server after an
                      operation is executed. This is useful when queries return small
                      result sets.
            raw: If `True`, the cursor skips the conversion from MySQL data types to
                 Python types when fetching rows. A raw cursor is usually used to get
                 better performance or when you want to do the conversion yourself.
            prepared: If `True`, the cursor is used for executing prepared statements.
            cursor_class: It can be used to pass a class to use for instantiating a
                          new cursor. It must be a subclass of `cursor.CursorBase` or
                          `cursor_cext.CMySQLCursor` according to the type of connection
                          that's being used.
            dictionary: If `True`, the cursor returns rows as dictionaries.
            named_tuple: If `True`, the cursor returns rows as named tuples.

        Returns:
            cursor: A cursor object.

        Raises:
            ProgrammingError: When `cursor_class` is not a subclass of
                              `MySQLCursorAbstract`.
            ValueError: When cursor is not available.
        NrH   )r   bufferedrawpreparedcursor_class
dictionarynamed_tuples          rJ   cursorzMySQLConnectionAbstract.cursor  r   rI   c                     y)zExecutes a query.NrH   r  s     rJ   r  z&MySQLConnectionAbstract._execute_query  r   rI   c                     y)a  Rollbacks current transaction.

        Sends a ROLLBACK statement to the MySQL server, undoing all data changes
        from the current transaction. By default, Connector/Python does not
        autocommit, so it is possible to cancel transactions when using
        transactional storage engines such as `InnoDB`.

        Examples:
            ```
            >>> stmt = "INSERT INTO employees (first_name) VALUES (%s), (%s)"
            >>> cursor.execute(stmt, ('Jane', 'Mary'))
            >>> cnx.rollback()
            ```
        NrH   r   s    rJ   rollbackz MySQLConnectionAbstract.rollback  r   rI   c                   | j                   rt        d      |rY|j                         j                  dd      j	                         }g d}||vrt        d| d      | j                  d|        |C| j                  d	k  rt        d
| j                   d      |rd}nd}| j                  d|        d}|r|dz  }| j                  |       y)an  Starts a transaction.

        This method explicitly starts a transaction sending the
        START TRANSACTION statement to the MySQL server. You can optionally
        set whether there should be a consistent snapshot, which
        isolation level you need or which access mode i.e. READ ONLY or
        READ WRITE.

        Args:
            consistent_snapshot: If `True`, Connector/Python sends WITH CONSISTENT
                                 SNAPSHOT with the statement. MySQL ignores this for
                                 isolation levels for which that option does not apply.
            isolation_level: Permitted values are 'READ UNCOMMITTED', 'READ COMMITTED',
                             'REPEATABLE READ', and 'SERIALIZABLE'. If the value is
                             `None`, no isolation level is sent, so the default level
                             applies.
            readonly: Can be `True` to start the transaction in READ ONLY mode or
                      `False` to start it in READ WRITE mode. If readonly is omitted,
                      the server's default access mode is used.

        Raises:
            ProgrammingError: When a transaction is already in progress
                              and when `ValueError` when `isolation_level`
                              specifies an Unknown level.

        Examples:
            For example, to start a transaction with isolation level `SERIALIZABLE`,
            you would do the following:
            ```
            >>> cnx = mysql.connector.connect(...)
            >>> cnx.start_transaction(isolation_level='SERIALIZABLE')
            ```
        zTransaction already in progressr    )zREAD UNCOMMITTEDzREAD COMMITTEDzREPEATABLE READSERIALIZABLEzUnknown isolation level ""z SET TRANSACTION ISOLATION LEVEL N)      r  zMySQL server version z does not support this featurez	READ ONLYz
READ WRITEzSET TRANSACTION zSTART TRANSACTIONz WITH CONSISTENT SNAPSHOT)	rr  r-   r   r:  r   r9  r  r^   r   )r   consistent_snapshotisolation_levelreadonlylevellevelsaccess_moder  s           rJ   start_transactionz)MySQLConnectionAbstract.start_transaction#  s    N "#DEE#))+33C=CCEEF F" #<_<MQ!OPP"B5' JK##i/ +D,@,@+A B+ + 
 )*"2;- @A#00EurI   c                <   | j                         st        d      	 | j                          |s|r| j                         }|r/|j                         D ]  \  }}|j                  d| d|         |r/|j                         D ]  \  }}|j                  d| d|         |j                          yy# t        t        f$ rW | j
                  rt        d      d| j                  | j                  | j                  | j                  | 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.

        Args:
            user_variables: User variables map.
            session_variables: System variables map.

        Raises:
            OperationalError: If not connected.
            InternalError: If there are unread results and InterfaceError on errors.

        Examples:
            ```
            >>> user_variables = {'var1': '1', 'var2': '10'}
            >>> session_variables = {'wait_timeout': 100000, 'sql_mode': 'TRADITIONAL'}
            >>> cnx.reset_session(user_variables, session_variables)
            ```
        zMySQL Connection not availablezYReset session is not supported with compression for MySQL server version 5.7.2 or earlierNzSET @`z` = zSET SESSION `)r  r,   cmd_reset_connectionr+   rx  r   cmd_change_userra   rb   rf   rZ   r  r   executer   )r   user_variablessession_variablescurr  r   s         rJ   reset_sessionz%MySQLConnectionAbstract.reset_sessionm  s#   <   ""#CDD	%%' .++-C"0"6"6"8 ;JCKK&T% 9:; "3"9"9"; BJCKK-uD @ABIIK / "#67 	~~'<    

  		s   B5 5A#DDc                   |rst        |t              rc| j                  j                  | j                        d   }|| _         ||| j                        | _        | j                  | j                  _	        yt        d      )z
        Sets the converter class to be used.

        Args:
            convclass: Should be a class overloading methods and members of
                       `conversion.MySQLConverter`.
        r   zFConverter class should be a subclass of conversion.MySQLConverterBase.N)
issubclassr'   r   r  rZ   r   rt   r   r   str_fallbackr6  )r   	convclassr  s      rJ   r5  z+MySQLConnectionAbstract.set_converter_class  sp     I/AB..778H8HI!LL$-D!&|T5F5FGDN*.*F*FDNN'X rI   c                     y)a  Retrieves the next row of a query result set.

        Args:
            binary: If `True`, read as binary result (only meaningful for pure Python
                    connections).
            columns: Field types (only meaningful for pure Python connections and when
                     `binary=True`).
            raw: If `True`, the converter class does not convert the parsed values.
            prep_stmt: Prepared statement object (only meaningful for
                       C-ext connections).

        Returns:
            tuple: The row as a tuple (RowType) containing byte objects, or `None` when
                   no more rows are available. (at position 0). EOF packet
                   information as a dictionary containing `status_flag` and
                   `warning_count` (at position 1).

        Raises:
            InterfaceError: When all rows have been retrieved.
        NrH   )r   r  columnsr  	prep_stmts        rJ   get_rowzMySQLConnectionAbstract.get_row  r   rI   c                     y)a  Gets all rows returned by the MySQL server.

        Args:
            count: Used to obtain a given number of rows. If set to `None`, all
                   rows are fetched.
            binary: If `True`, read as binary result (only meaningful for pure Python
                    connections).
            columns: Field types (only meaningful for pure Python connections and when
                     `binary=True`).
            raw: If `True`, the converter class does not convert the parsed values.
            prep_stmt: Prepared statement object (only meaningful for
                       C-ext connections).

        Returns:
            tuple: A list of tuples (RowType) containing the row data as byte objects,
                   or an empty list when no rows are available (at position 0).
                   EOF packet information as a dictionary containing `status_flag`
                   and `warning_count` (at position 1).

        Raises:
            InterfaceError: When all rows have been retrieved.
        NrH   )r   countr  r  r  r  s         rJ   get_rowsz MySQLConnectionAbstract.get_rows  r   rI   c                     y)a  Changes the current database.

        This method makes specified database the default (current) database.
        In subsequent queries, this database is the default for table references
        that include no explicit database qualifier.

        Args:
            database: Database to become the default (current) database.

        Returns:
            ok_packet: Dictionary containing the OK packet information.
        NrH   )r   r   s     rJ   cmd_init_dbz#MySQLConnectionAbstract.cmd_init_db  r   rI   c                     y)a  Sends a query to the MySQL server.

        This method sends the query to the MySQL server and returns the result. To send
        multiple statements, use the `cmd_query_iter()` method instead.

        The returned dictionary contains information depending on what kind of query
        was executed. If the query is a `SELECT` statement, the result contains
        information about columns. Other statements return a dictionary containing
        OK or EOF packet information.

        Errors received from the MySQL server are raised as exceptions.

        Arguments `raw`, `buffered` and `raw_as_string` are only meaningful
        for `C-ext` connections.

        Args:
            query: Statement to be executed.
            raw: If `True`, the cursor skips the conversion from MySQL data types to
                 Python types when fetching rows. A raw cursor is usually used to get
                 better performance or when you want to do the conversion yourself. If
                 not provided, take its value from the MySQL instance.
            buffered: If `True`, the cursor fetches all rows from the server after an
                      operation is executed. This is useful when queries return small
                      result sets.
            raw_as_string: Is a special argument for Python v2 and returns `str`
                           instead of `bytearray`.

        Returns:
            dictionary: `Result` or `OK packet` information

        Raises:
            InterfaceError: When multiple results are found.
        NrH   )r   r  r  r  raw_as_strings        rJ   r   z!MySQLConnectionAbstract.cmd_query  r   rI   c                     y)aZ  Sends one or more statements to the MySQL server.

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

        Use `cmd_query_iter()` when sending multiple statements, and separate
        the statements with semicolons.

        Args:
            statements: Statements to be executed separated with semicolons.

        Returns:
            generator: Generator object with `Result` or `OK packet` information.

        Examples:
            The following example shows how to iterate through the results after
            sending multiple statements:
            ```
            >>> statement = 'SELECT 1; INSERT INTO t1 VALUES (); SELECT 2'
            >>> for result in cnx.cmd_query_iter(statement):
            >>> if 'columns' in result:
            >>>     columns = result['columns']
            >>>     rows = cnx.get_rows()
            >>> else:
            >>>     # do something useful with INSERT result
            ```
        NrH   )r   
statementss     rJ   cmd_query_iterz&MySQLConnectionAbstract.cmd_query_iter/  r   rI   c                     y)a  Sends the Refresh command to the MySQL server.

        `WARNING: This MySQL Server functionality is deprecated.`

        This method flushes tables or caches, or resets replication server
        information. The connected user must have the RELOAD privilege.

        The options argument should be a bitmask value constructed using
        constants from the `constants.RefreshOption` class.

        The result is a dictionary with the OK packet information.

        Args:
            options: Bitmask value constructed using constants from
                     the `constants.RefreshOption` class.

        Returns:
            dictionary: OK packet information.

        Examples:
            ```
            >>> from mysql.connector import RefreshOption
            >>> refresh = RefreshOption.LOG | RefreshOption.THREADS
            >>> cnx.cmd_refresh(refresh)
            ```
        NrH   )r   optionss     rJ   cmd_refreshz#MySQLConnectionAbstract.cmd_refreshP  r   rI   c                     y)a  Closes the current connection with the server.

        This method sends the `QUIT` command to the MySQL server, closing the
        current connection. Since there is no response from the MySQL server,
        the packet that was sent is returned.

        Returns:
            packet_sent: `None` when using a C-ext connection,
                         else the actual packet that was sent.
        NrH   r   s    rJ   cmd_quitz MySQLConnectionAbstract.cmd_quitm  r   rI   c                     y)zShuts 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.
        NrH   )r   shutdown_types     rJ   cmd_shutdownz$MySQLConnectionAbstract.cmd_shutdownz  r   rI   c                     y)a  Sends the statistics command to the MySQL Server.

        Returns:
            dict: Stats packet information about the MySQL server including uptime
                  in seconds and the number of running threads, questions, reloads, and
                  open tables.
        NrH   r   s    rJ   cmd_statisticsz&MySQLConnectionAbstract.cmd_statistics  r   rI   c                     t        d      )a|  Get the process list of the MySQL Server.

        This method is a placeholder to notify that the PROCESS_INFO command
        is not supported by raising the `NotSupportedError`.

        The command
        "SHOW PROCESSLIST" should be send using the cmd_query()-method or
        using the `INFORMATION_SCHEMA` database.

        Raises `NotSupportedError` exception.
        z;Not implemented. Use SHOW PROCESSLIST or INFORMATION_SCHEMA)r+   rH   rI   rJ   cmd_process_infoz(MySQLConnectionAbstract.cmd_process_info  s      I
 	
rI   c                     y)a  Kills a MySQL process.

        Asks the server to kill the thread specified by `mysql_pid`. Although
        still available, it is better to use the KILL SQL statement.

        Args:
            mysql_pid: Process ID to be killed.

        Returns:
            ok_packet: Dictionary containing the OK packet information.

        Examples:
            ```
            >>> cnx.cmd_process_kill(123)  # using cmd_process_kill()
            >>> cnx.cmd_query('KILL 123')  # alternatively (recommended)
            ```
        NrH   )r   	mysql_pids     rJ   cmd_process_killz(MySQLConnectionAbstract.cmd_process_kill  r   rI   c                     y)zInstructs the server to write debugging information to the error log.

        The connected user must have the `SUPER` privilege.

        Returns:
            ok_packet: Dictionary containing the EOF (end-of-file) packet information.
        NrH   r   s    rJ   	cmd_debugz!MySQLConnectionAbstract.cmd_debug  r   rI   c                     y)zChecks whether the connection to the server is working.

        This method is not to be used directly. Use `ping()` or
        `is_connected()` instead.

        Returns:
            ok_packet: Dictionary containing the OK packet information.
        NrH   r   s    rJ   cmd_pingz MySQLConnectionAbstract.cmd_ping  r   rI   c
                     y)a  Changes the current logged in user.

        It also causes the specified database to become the default (current)
        database. It is also possible to change the character set using the
        charset argument.

        Args:
            username: New account's username.
            password: New account's password.
            database: Database to become the default (current) database.
            charset: Client charset (see [1]), only the lower 8-bits.
            password1: New account's password factor 1 - it's used instead
                       of `password` if set (higher precedence).
            password2: New account's password factor 2.
            password3: New account's password factor 3.
            oci_config_file: OCI configuration file location (path-like string).
            oci_config_profile: OCI configuration profile location (path-like string).

        Returns:
            ok_packet: Dictionary containing the OK packet information.

        Examples:
            ```
            >>> cnx.cmd_change_user(username='', password='', database='', charset=33)
            ```

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_basic_character_set.html#a_protocol_character_set
        NrH   )
r   r  r  r   r  	password1	password2	password3oci_config_fileoci_config_profiles
             rJ   r  z'MySQLConnectionAbstract.cmd_change_user  r   rI   c                     y)a%  Prepares a MySQL statement.

        Args:
            statement: statement to prepare.

        Returns:
            prepared_stmt: A `Prepared Statement` structure - a dictionary
                           is returned when using a pure Python connection, and a
                           `_mysql_connector.MySQLPrepStmt` object is returned when
                           using a C-ext connection.

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/
                page_protocol_com_stmt_prepare.html
        NrH   )r   	statements     rJ   cmd_stmt_preparez(MySQLConnectionAbstract.cmd_stmt_prepare  r   rI   c                     y)aF  Executes a prepared MySQL statement.

        Args:
            statement_id: Statement ID found in the dictionary returned by
                          `MySQLConnection.cmd_stmt_prepare` when using a pure Python
                          connection, or a `_mysql_connector.MySQLPrepStmt` instance
                          as returned by `CMySQLConnection.cmd_stmt_prepare` when
                          using a C-ext connection.
            data: Data sequence against which the prepared statement will be executed.
            parameters: Currently unused!
            flags: see [1].

        Returns:
            dictionary or tuple: `OK packet` or `Result` information.

        Notes:
            The previous method's signature applies to pure Python, the C-ext has
            the following signature:

            ```
            def cmd_stmt_execute(
                self, statement_id: CMySQLPrepStmt, *args: Any
            ) -> Optional[Union[Dict[str, Any], Tuple]]:
            ```

            You should expect a similar returned value type, however, the input
            is different. In this case `data` must be provided as positional
            arguments instead of a sequence.

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_com_stmt_execute.html
        NrH   )r   statement_iddatarT  ru  s        rJ   cmd_stmt_executez(MySQLConnectionAbstract.cmd_stmt_execute  r   rI   c                     y)a  Deallocates a prepared MySQL statement.

        Args:
            statement_id: Statement ID found in the dictionary returned by
                          `MySQLConnection.cmd_stmt_prepare` when using a pure Python
                          connection, or a `_mysql_connector.MySQLPrepStmt` instance
                          as returned by `CMySQLConnection.cmd_stmt_prepare` when
                          using a C-ext connection.
        NrH   r   r   s     rJ   cmd_stmt_closez&MySQLConnectionAbstract.cmd_stmt_close0  r   rI   c                     y)a?  Sends data for a column.

        Currently, not implemented for the C-ext.

        Args:
            statement_id: Statement ID found in the dictionary returned by
                          `MySQLConnection.cmd_stmt_prepare` when using a pure Python
                          connection, or a `_mysql_connector.MySQLPrepStmt` instance
                          as returned by `CMySQLConnection.cmd_stmt_prepare` when
                          using a C-ext connection.
            param_id: The parameter to supply data to [1].
            data: The actual payload to send [1].

        Returns:
            total_sent: The total number of bytes that were sent is returned.

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_com_stmt_send_long_data.html
        NrH   )r   r   param_idr!  s       rJ   cmd_stmt_send_long_dataz/MySQLConnectionAbstract.cmd_stmt_send_long_data<  r   rI   c                     y)a  Resets data for prepared statement sent as long data.

        Args:
            statement_id: Statement ID found in the dictionary returned by
                          `MySQLConnection.cmd_stmt_prepare` when using a pure Python
                          connection, or a `_mysql_connector.MySQLPrepStmt` instance
                          as returned by `CMySQLConnection.cmd_stmt_prepare` when
                          using a C-ext connection.
        NrH   r$  s     rJ   cmd_stmt_resetz&MySQLConnectionAbstract.cmd_stmt_resetU  r   rI   c                     y)aN  Resets the session state without re-authenticating.

        Reset command only works on MySQL server 5.7.3 or later.

        This method permits the session state to be cleared without reauthenticating.
        For MySQL servers older than 5.7.3 (when `COM_RESET_CONNECTION` was introduced)
        , the `reset_session()` method can be used instead - that method resets the
        session state by reauthenticating, which is more expensive.

        This method was added in Connector/Python 1.2.1.

        Returns:
            `True` for a successful reset otherwise `False`.
        NrH   r   s    rJ   r  z,MySQLConnectionAbstract.cmd_reset_connectiona  r   rI   returnNone)r-  rL   r   zType[BaseException]r   BaseExceptionr   r   r-  r.  )r-  r   )r-  z$List[Tuple[str, BinaryProtocolType]])r   zTuple[str, BinaryProtocolType]r-  r.  r   r   r-  r7   )r-  r   r-  r8  )r-  Optional[str])r   r   r-  r.  )r   r   r-  r.  )r-  r   )r   r   r-  r.  )rF  r   r-  r.  )r   )rU  r   rV  zUnion[str, Callable]rW  r8  r-  r.  )rh  r=   r-  zTuple[int, ...])r-  zOptional[Tuple[int, ...]])ru  zUnion[int, Sequence[int]]r-  r8  r-  r   )rv  r8  r-  r   )r   zUnion[str, Sequence[int]]r-  r.  )r  r   r-  zOptional[RowType])NN)r  r3  r  r3  r-  r.  T)r  zOptional[Union[int, str]]r  r3  r-  r.  r-  Optional[int])r   r   )r  r8  r  r8  r-  r.  )Fr   r   )r  r   r  r8  r  r8  r-  r.  )NNNNNN)r  Optional[bool]r  r8  r  r8  r  z%Optional[Type['MySQLCursorAbstract']]r  r8  r  r8  r-  z'MySQLCursorAbstract')r  r   r-  r.  )FNN)r  r   r  r3  r  r8  r-  r.  )r  Optional[Dict[str, Any]]r  r9  r-  r.  )r  zOptional[Type[MySQLConverter]]r-  r.  )FNNN)
r  r   r  Optional[List[DescriptionType]]r  r8  r  Optional[CMySQLPrepStmt]r-  z2Tuple[Optional[RowType], Optional[Dict[str, Any]]])NFNNN)r  r7  r  r   r  r:  r  r8  r  r;  r-  z.Tuple[List[RowType], Optional[Dict[str, Any]]])r   r   r-  r9  )FFF)
r  r   r  r8  r  r   r  r   r-  r9  )r  r   r-  z(Generator[Mapping[str, Any], None, None])r  r8  r-  r9  )r-  zOptional[bytes]r   )r	  r7  r-  r.  )r-  r9  )r  r8  r-  r9  )	rP   rP   rP   rO   rP   rP   rP   rP   rP   )r  r   r  r   r   r   r  r8  r  r   r  r   r  r   r  r   r  r   r-  r9  )r  ra  r-  z(Union[Mapping[str, Any], CMySQLPrepStmt])rH   rH   r   )
r   Union[int, CMySQLPrepStmt]r!  zSequence[BinaryProtocolType]rT  r   ru  r8  r-  z&Optional[Union[Dict[str, Any], Tuple]])r   r<  r-  r.  )r   r<  r'  r8  r!  r   r-  r8  )XrD   rE   rF   rG   r   r   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   setterr   r   rG  r?  staticmethodrE  rk  rm  rp  rr  r-  ry  r{  r  r  r~  r7  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   __annotations__r  r  r  r  r  r  r  r  r  r  r5  r  r  r  r   r  r  r  r
  r  r  r  r  r  r  r  r"  r%  r(  r*  r  rH   rI   rJ   rL   rL      s   BB;H% ! !	
 
 
 
 & & / /61Q
fPRd       ! ! $  $ __' ' % % &  &
 ) ) *  *vTp	6 JK  $8 DG 	   D  2$
   (&"P	"/ 
 
    
   __ $  & IM % 8E 	 (
.  
 ! ! " " 
# 
# ' ' ' '& # # 
$ 
$ 	A 	A    UYHX0HXDQHX	HXT 	I 	I #  # M M 8 84     *E)4Ll48l    .  &  $("#'>B%)&*. . . !	.
 <. #. $. 
. .`      $ %*)-#'	H!H 'H !	H
 
HX 486:808 48 
	8t$  37".2 1 	
 , 
< 8   $37".2  1	
  , 
8 >    $#'' ' 	'
 ' 
"' 'R 	1 @  8 
 
     
 
   &      !"$)) ) 	)
 ) ) ) ) )  ) 
") )V 	1 &  .0!'0' +' 	'
 ' 
0' 'R 	 	 6BEMU	 0 	 	  rI   rL   c                     e Zd ZdZddZddZ	 	 	 	 	 	 	 	 ddZe	 d	 	 	 	 	 d d       Zedd       Z	e	 	 d!	 	 	 	 	 	 	 d"d       Z
e	 	 	 	 	 	 d#d       Zed$d	       Zed%d&d
       Zed'd       Zed(d       Zd)dZd*dZd+d,dZd-d.dZeed/d              Zeed0d              Zed1d       Zed2d       Zed0d       Zd2dZd3dZd4dZd5dZddZy)6MySQLCursorAbstractzAbstract cursor class

    Abstract class defining cursor class with method and members
    required by the Python Database API Specification v2.0.
    c                    d| _         d| _        d| _        d| _        d| _        d| _        g | _        g | _        d| _        y)InitializationNr   r   r   )	_description	_rowcount_last_insert_id	_warnings_warning_count	_executed_executed_list_stored_results	arraysizer   s    rJ   r   zMySQLCursorAbstract.__init__z  sF    =A .26:#$*.02:<rI   c                    | S r   rH   r   s    rJ   r   zMySQLCursorAbstract.__enter__  r   rI   c                $    | j                          y r   r   r   s       rJ   r   zMySQLCursorAbstract.__exit__  r   rI   c                     y)a  Calls a stored procedure with the given arguments.

        The arguments will be set during this session, meaning they will be called like
        _<procname>__arg<nr> where <nr> is an enumeration (+1) of the arguments.

        Args:
            procname: The stored procedure name.
            args: Sequence of parameters - it must contain one entry for each argument
                  that the procedure expects.

        Returns:
            Does not return a value, but a result set will be available when the
            CALL-statement executes successfully.

            `callproc()` returns a modified copy of the input sequence. `Input`
            parameters are left untouched. `Output` and `input/output` parameters may
            be replaced with new values.

            Result sets produced by the stored procedure are automatically fetched and
            stored as `MySQLCursorBuffered` instances.

            The value returned (if any) is a `Dict` when cursor's subclass is
            `MySQLCursorDict`, else a `Tuple` (RowType).

        Raises:
            InterfaceError: When something is wrong

        Examples:
            1) Defining the Stored Routine in MySQL:
            ```
            CREATE PROCEDURE multiply(IN pFac1 INT, IN pFac2 INT, OUT pProd INT)
            BEGIN
            SET pProd := pFac1 * pFac2;
            END;
            ```

            2) Executing in Python:
            ```
            >>> args = (5, 6, 0) # 0 is to hold value of the OUT parameter pProd
            >>> cursor.callproc('multiply', args)
            ('5', '6', 30L)
            ```

        References:
            [1]: https://dev.mysql.com/doc/connector-python/en/                connector-python-api-mysqlcursor-callproc.html
        NrH   )r   procnameargss      rJ   callproczMySQLCursorAbstract.callproc  r   rI   c                     y)a=  Close the cursor.

        Use close() when you are done using a cursor. This method closes the cursor,
        resets all results, and ensures that the cursor object has no reference to its
        original connection object.

        This method is part of PEP 249 - Python Database API Specification v2.0.
        NrH   r   s    rJ   r   zMySQLCursorAbstract.close  r   rI   c                     y)aZ  Executes the given operation substituting any markers with the given parameters.

        For example, getting all rows where id is 5:
        ```
        >>> cursor.execute("SELECT * FROM t1 WHERE id = %s", (5,))
        ```

        The `multi` argument should be set to `True` when executing multiple
        statements in one operation.

        If warnings were generated, and `connection.get_warnings` is `True`, then
        `self.warnings` will be a list containing these warnings.

        Args:
            operation: Operation to be executed.
            params: The parameters found in the tuple or dictionary params are bound
                    to the variables in the operation. Specify variables using `%s` or
                    `%(name)s` parameter style (that is, using format or pyformat style).
            multi: If `multi` is set to `True`, `execute()` is able to execute multiple
                   statements specified in the operation string.

        Returns:
            An iterator when `multi` is `True`, otherwise `None`.

        Raises:
            InterfaceError: If `multi` is not set and multiple results are found.

        Examples:
            The following example selects and inserts data in a single `execute()`
            operation and displays the result of each statement:

            ```
            >>> operation = 'SELECT 1; INSERT INTO t1 VALUES (); SELECT 2'
            >>> for result in cursor.execute(operation, multi=True):
            >>>     if result.with_rows:
            >>>         print("Rows produced by statement '{}':".format(
            >>>         result.statement))
            >>>         print(result.fetchall())
            >>>     else:
            >>>         print("Number of rows affected by statement '{}': {}".format(
            >>>         result.statement, result.rowcount))
            ```
        NrH   )r   	operationparamsmultis       rJ   r  zMySQLCursorAbstract.execute  r   rI   c                     y)a  Executes the given operation multiple times.

        The `executemany()` method will execute the operation iterating
        over the list of parameters in `seq_params`.

        `INSERT` statements are optimized by batching the data, that is
        using the MySQL multiple rows syntax.

        Args:
            operation: Operation to be executed.
            seq_params: Parameters to be used when executing the operation.

        Returns:
            Results are discarded. If they are needed, consider looping over data
            using the `execute()` method.

        Examples:
            An optimization is applied for inserts: The data values given by the
            parameter sequences are batched using multiple-row syntax. The following
            example inserts three records:

            ```
            >>> data = [
            >>> ('Jane', date(2005, 2, 12)),
            >>> ('Joe', date(2006, 5, 23)),
            >>> ('John', date(2010, 10, 3)),
            >>> ]
            >>> stmt = "INSERT INTO employees (first_name, hire_date) VALUES (%s, %s)"
            >>> cursor.executemany(stmt, data)
            ```

            For the preceding example, the INSERT statement sent to MySQL is:
            ```
            >>> INSERT INTO employees (first_name, hire_date)
            >>> VALUES ('Jane', '2005-02-12'), ('Joe', '2006-05-23'), ('John', '2010-10-03')
            ```
        NrH   )r   rV  
seq_paramss      rJ   executemanyzMySQLCursorAbstract.executemany	  r   rI   c                     y)a  Retrieves next row of a query result set

        Returns:
            If the cursor's subclass is `MySQLCursorDict`, a dictionaries is
            returned, otherwise a tuple (RowType). `None` is returned when there aren't
            results to be read.

        Examples:
            ```
            >>> cursor.execute("SELECT * FROM employees")
            >>> row = cursor.fetchone()
            >>> while row is not None:
            >>>     print(row)
            >>>     row = cursor.fetchone()
            ```
        NrH   r   s    rJ   fetchonezMySQLCursorAbstract.fetchone3	  r   rI   c                     y)a  Fetches the next set of rows of a query result.

        Args:
            size: The number of rows returned can be specified using the size
                  argument, which is one by default.

        Returns:
            If the cursor's subclass is `MySQLCursorDict`, a list of dictionaries is
            returned, otherwise a list of tuples (RowType). When no more rows are
            available, it returns an empty list.
        NrH   )r   sizes     rJ   	fetchmanyzMySQLCursorAbstract.fetchmanyF	  r   rI   c                     y)a  Fetches all (or all remaining) rows of a query result set.

        Returns:
            If the cursor's subclass is `MySQLCursorDict`, a list of dictionaries is
            returned, otherwise a list of tuples (RowType).

        Examples:
            ```
            >>> cursor.execute("SELECT * FROM employees ORDER BY emp_no")
            >>> head_rows = cursor.fetchmany(size=2)
            >>> remaining_rows = cursor.fetchall()
            ```
        NrH   r   s    rJ   fetchallzMySQLCursorAbstract.fetchallT	  r   rI   c                     y)a  Returns an iterator (of MySQLCursorAbstract subclass instances) for stored results.

        This method returns an iterator over results which are stored when
        callproc() is called. The iterator will provide `MySQLCursorBuffered`
        instances.

        Examples:
            ```
            >>> cursor.callproc('myproc')
            ()
            >>> for result in cursor.stored_results():
            ...     print result.fetchall()
            ...
            [(1,)]
            [(2,)]
            ```
        NrH   r   s    rJ   stored_resultsz"MySQLCursorAbstract.stored_resultsd	  r   rI   c                     yzNot Implemented.NrH   r   s    rJ   nextsetzMySQLCursorAbstract.nextsetx	  r   rI   c                     yrf  rH   )r   sizess     rJ   setinputsizesz!MySQLCursorAbstract.setinputsizes{	  r   rI   Nc                     yrf  rH   )r   r_  columns      rJ   setoutputsizez!MySQLCursorAbstract.setoutputsize~	  r   rI   c                     y)zResets the cursor to defaultNrH   )r   frees     rJ   resetzMySQLCursorAbstract.reset	  r   rI   c                    | j                   S )a^  This read-only property returns a list of tuples describing the columns in a
        result set.

        A tuple is described as follows::
        ```
        (column_name,
            type,
            None,
            None,
            None,
            None,
            null_ok,
            column_flags)  # Addition to PEP-249 specs
        ```

        See [1] for more details and examples.

        Returns:
            A list of tuples.

        References:
            [1]: https://dev.mysql.com/doc/connector-python/en/                connector-python-api-mysqlcursor-description.html
        )rE  r   s    rJ   descriptionzMySQLCursorAbstract.description	  s    6    rI   c                    | j                   S )a  Returns the number of rows produced or affected.

        This property returns the number of rows produced by queries
        such as `SELECT`, or affected rows when executing DML statements
        like `INSERT` or `UPDATE`.

        Note that for non-buffered cursors it is impossible to know the
        number of rows produced before having fetched them all. For those,
        the number of rows will be -1 right after execution, and
        incremented when fetching rows.

        Returns an integer.
        )rF  r   s    rJ   rowcountzMySQLCursorAbstract.rowcount	  s      ~~rI   c                    | j                   S )a  Returns the value generated for an AUTO_INCREMENT column.

        Returns the value generated for an AUTO_INCREMENT column by
        the previous INSERT or UPDATE statement or `None` when there is
        no such a value available.

        Returns a long value or `None`.
        )rG  r   s    rJ   	lastrowidzMySQLCursorAbstract.lastrowid	  s     ###rI   c                    | j                   S )a  Returns a list of tuples (WarningType) containing warnings generated
        by the previously executed operation.

        Examples:
            ```
            >>> cnx.get_warnings = True
            >>> cursor.execute("SELECT 'a'+1")
            >>> cursor.fetchall()
            [(1.0,)]
            >>> cursor.warnings
            [(u'Warning', 1292, u"Truncated incorrect DOUBLE value: 'a'")]
            ```
        rH  r   s    rJ   rB  zMySQLCursorAbstract.warnings	  s     ~~rI   c                    | j                   S )zReturns the number of warnings.

        This property returns the number of warnings generated by the
        previously executed operation.

        Returns an integer value.
        )rI  r   s    rJ   warning_countz!MySQLCursorAbstract.warning_count	  r  rI   c                    | j                   S )a  Returns a list of tuples (WarningType) containing warnings generated by
        the previously executed operation.

        Examples:
            ```
            >>> cnx.get_warnings = True
            >>> cursor.execute("SELECT 'a'+1")
            >>> cursor.fetchall()
            [(1.0,)]
            >>> cursor.fetchwarnings()
            [(u'Warning', 1292, u"Truncated incorrect DOUBLE value: 'a'")]
            ```
        rx  r   s    rJ   fetchwarningsz!MySQLCursorAbstract.fetchwarnings	  s     ~~rI   c                    t        | d      r| j                  j                  S t        | d      r| j                  j                  S y)zGets a list of query attributes from the connector's side.

        Returns:
            List of existing query attributes.
        _cnx_connectionN)hasattrr~  r   r  r   s    rJ   get_attributesz"MySQLCursorAbstract.get_attributes	  s=     4 99(((4'##///rI   c                $   t        |t              st        d      |t        |t              st        d| d      t	        | d      r| j
                  j                  ||f       yt	        | d      r| j                  j                  ||f       yy)a  Adds a query attribute and its value into the connector's query attributes list.

        Query attributes must be enabled on the server - they are disabled by default. A
        warning is logged when setting query attributes for a server connection
        that does not support them.

        Args:
            name: Key name used to identify the attribute.
            value: A value converted to the MySQL Binary Protocol.

        Raises:
            ProgrammingError: If the value's conversion fails.
        &Parameter `name` must be a string typeNzObject z$ cannot be converted to a MySQL typer~  r  )r   r   r-   MYSQL_PY_TYPESr  r~  r   r  )r   r   r   s      rJ   add_attributez!MySQLCursorAbstract.add_attribute	  s     $$"#KLLZ~%F"% DE  4 II(($7T=)//u> *rI   c                    t        |t              st        d      t        | d      r| j                  j                  |      S t        | d      r| j                  j                  |      S y)a,  Removes a query attribute by name from the connector's query attributes list.

        If no match, `None` is returned, else the corresponding value is returned.

        Args:
            name: Key name used to identify the attribute.

        Returns:
            value: Attribute's value.
        r  r~  r  N)r   r   r-   r  r~  r   r  r   s     rJ   remove_attributez$MySQLCursorAbstract.remove_attribute
  s]     $$"#KLL4 99//554'##66t<<rI   c                    t        | d      r| j                  j                          yt        | d      r| j                  j                          yy)z<Clears the list of query attributes on the connector's side.r~  r  N)r  r~  r   r  r   s    rJ   clear_attributesz$MySQLCursorAbstract.clear_attributes#
  s=    4 II'')T=)..0 *rI   r,  )r-  rB  r/  )rH   )rQ  r   rR  r   r-  z0Optional[Union[Dict[str, RowItemType], RowType]])rH   F)rV  r   rW  zFUnion[Sequence[MySQLConvertibleType], Dict[str, MySQLConvertibleType]]rX  r   r-  4Optional[Generator[MySQLCursorAbstract, None, None]])rV  r   rZ  zPSequence[Union[Sequence[MySQLConvertibleType], Dict[str, MySQLConvertibleType]]]r-  r  )r-  z0Optional[Union[RowType, Dict[str, RowItemType]]])r   )r_  r8  r-  ,List[Union[RowType, Dict[str, RowItemType]]])r-  r  )r-  zIterator[MySQLCursorAbstract]r4  )ri  r   r-  r   r   )r_  r   rl  r   r-  r   r5  )ro  r   r-  r.  )r-  r:  r2  r6  )r-  zOptional[List[WarningType]])r-  z.Optional[List[Tuple[str, BinaryProtocolType]]])r   r   r   r7   r-  r.  r1  )rD   rE   rF   rG   r   r   r   r   rS  r   r  r[  r]  r`  rb  rd  rg  rj  rm  rp  r=  rr  rt  rv  rB  rz  r|  r  r  r  r  rH   rI   rJ   rB  rB  s  s   
 % ! !	
 
 .011#+1	91 1f    22
2 2 
>2 2h ++
+ 
>+ +Z  $      &+ !  !6     	$ 	$    # # 
?2&1rI   rB  )crG   
__future__r   r   rc  rB  weakrefabcr   r   r   r   r   r	   decimalr
   inspectr   r   typesr   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   sslr  r   ImportError	constantsr   r   r    r!   r"   r#   r$   r%   
conversionr&   r'   errorsr(   r)   r*   r+   r,   r-   opentelemetry.constantsr.   r/   r0   r1   opentelemetry.instrumentationr2   r3   r4   r5   optionfilesr6   r7   r8   r9   r:   r;   r<   r=   r>   utilsr?   r@   WeakValueDictionaryrA   r@  r   r   r   r   rA  ra  floatr8  r   r  rC   rL   rB  rH   rI   rJ   <module>r     sf  > 2 " 	 	   # 4 4       "  	sM"s!
	 	 	 ;     +	 	 	 1;V7;V;V;X 8 X 2  O 
 P 
:  		
^ Ec EP>u1# u1]A  		s   )D9 9E E