
    9?h                       S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	  SSK
JrJrJrJrJrJrJrJrJrJrJr  SSKJr  SS	KJrJrJr  SS
KJr  SSKJrJrJ r J!r!J"r"  SSK#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-  Sr.\R^                  " S\. S\. S3\R`                  \Rb                  -  \Rd                  -  5      r3\R^                  " S\R`                  \Rb                  -  \Rd                  -  5      r4\R^                  " S\. S\. S3\R`                  \Rb                  -  \Rd                  -  5      r5\R^                  " S\R`                  \Rb                  -  \Rd                  -  5      r6\R^                  " S5      r7\R^                  " S\Rp                  5      r9\R^                  " S5      r:\R^                  " S5      r;\R^                  " S5      r<\R^                  " S5      r=Sr>Sr? " S S5      r@S:S jrA " S  S!\5      rB " S" S#\B5      rC " S$ S%\C5      rD " S& S'\C5      rE " S( S)\D5      rF " S* S+\C5      rG " S, S-\C5      rH " S. S/\C5      rI " S0 S1\H\D5      rJ " S2 S3\I\D5      rK " S4 S5\H\G5      rL " S6 S7\I\G5      rM " S8 S9\G5      rNg);zCursor classes.    )annotationsN)
namedtuple)Decimal)AnyDict	GeneratorIteratorListNoReturnOptionalSequenceTupleTypeUnion)CallableProxyType   )NAMED_TUPLE_CACHEMySQLConnectionAbstractMySQLCursorAbstract)
ServerFlag)ErrorInterfaceErrorNotSupportedErrorProgrammingErrorget_mysql_exception)
DescriptionTypeEofPacketTypeParamsDictTypeParamsSequenceOrDictTypeParamsSequenceType
ResultTypeRowType
StrOrBytesToPythonOutputTypesWarningTypez\/\*.*?\*\/(z)|(["'`][^"'`]*?(z)[^"'`]*?["'`])z<\s*ON\s+DUPLICATE\s+KEY(?:[^"'`]*["'`][^"'`]*["'`])*[^"'`]*$z|\s)*INSERT(z[|\s)*(?:IGNORE\s+)?INTO\s+[`'\"]?.+[`'\"]?(?:\.[`'\"]?.+[`'\"]?){0,2}\s+VALUES\s*(\(.+\)).*z.*VALUES\s*(\(.+\)).*s   (%s)sV   
    %
    \((?P<mapping_key>[^)]+)\)
    (?P<conversion_type>[diouxXeEfFgGcrs%])
    s%   ;(?=(?:[^"'`]*["'`].*["'`])*[^"'`]*$)s+   %s(?=(?:[^"'`]*["'`][^"'`]*["'`])*[^"'`]*$)z	%\(.*?\)sz%\((.*?)\)szNo result set to fetch froml    c                  @    \ rS rSrSrSS jrS	S jr\S
S j5       rSr	g)_ParamSubstitutorp   z,
Substitutes parameters into SQL statement.
c                    Xl         SU l        g Nr   )paramsindex)selfr,   s     ^/var/www/ev-aguas/ev-aguas-proceso/venv/lib/python3.13/site-packages/mysql/connector/cursor.py__init___ParamSubstitutor.__init__u   s    '-
    c                    U R                   nU =R                   S-  sl          [        U R                  U   5      $ ! [         a    [	        S5      S ef = f)Nr   z+Not enough parameters for the SQL statement)r-   bytesr,   
IndexErrorr   )r.   matchobjr-   s      r/   __call___ParamSubstitutor.__call__y   sS    



a
	U+,, 	"=	s	   ; Ac                F    [        U R                  5      U R                  -
  $ )z8Returns number of parameters remaining to be substituted)lenr,   r-   r.   s    r/   	remaining_ParamSubstitutor.remaining   s     4;;$**,,r2   )r-   r,   N)r,   zSequence[bytes]returnNoner6   re.Matchr>   r4   r>   int)
__name__
__module____qualname____firstlineno____doc__r0   r7   propertyr<   __static_attributes__ r2   r/   r(   r(   p   s%     - -r2   r(   c                B   ^ SU4S jjn[         R                  X 5      nU$ )a@  
>>> _bytestr_format_dict(b'%(a)s', {b'a': b'foobar'})
b'foobar
>>> _bytestr_format_dict(b'%%(a)s', {b'a': b'foobar'})
b'%%(a)s'
>>> _bytestr_format_dict(b'%%%(a)s', {b'a': b'foobar'})
b'%%foobar'
>>> _bytestr_format_dict(b'%(x)s %(y)s',
...                      {b'x': b'x=%(y)s', b'y': b'y=%(x)s'})
b'x=%(y)s y=%(x)s'
c                   > SnU R                  5       nUS   S:X  a  SnUS   S:X  a
  US   nTU   nUc  [        SUS    35      eU$ )zReplace pattern.Nconversion_type   %   smapping_keyzUnsupported conversion_type: )	groupdict
ValueError)r6   valuegroupskey
value_dicts       r/   replace%_bytestr_format_dict.<locals>.replace   st    !%##%#$,E#$,'CsOE=/7H0I/JK  r2   r@   )RE_PY_MAPPING_PARAMsub)bytestrrW   rX   stmts    `  r/   _bytestr_format_dictr^      s     ""74DKr2   c                    ^  \ rS rSr% SrSrS\S'   SU 4S jjrSSS jjrSS jr	  S       SS	 jjr
      SS
 jrSS jrSSS jjrSS jrSS jrS S jrS!S"S jjrS#S$S jjr\S%S j5       r\S&S j5       rSrU =r$ )'
CursorBase   z
Base for defining MySQLCursor. This class is a skeleton and defines
methods and members as required for the Python Database API
Specification v2.0.

It's better to inherite from MySQLCursor.
Fbool_rawc                L   > S U l         SU l        SU l        [        TU ]  5         g )Nr   )_description	_rowcount	arraysizesuperr0   r.   	__class__s    r/   r0   CursorBase.__init__   s$    =A r2   c                    g)a  Calls a stored procedue 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.

Coding Example:
  1) Definining 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,5,0) # 0 is to hold pprod
  cursor.callproc('multiply', args)
  print(cursor.fetchone())

Does not return a value, but a result set will be
available when the CALL-statement execute successfully.
Raises exceptions when something is wrong.
NrK   r.   procnameargss      r/   callprocCursorBase.callproc       r2   c                    g)zClose the cursor.NrK   r;   s    r/   closeCursorBase.close   rs   r2   c                    g)<  Executes the given operation

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 not set and multiple results are
found, an InterfaceError will be raised.

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

Returns an iterator when multi is True, otherwise None.
NrK   )r.   	operationr,   multis       r/   executeCursorBase.execute   rs   r2   c                    g)aO  Execute the given operation multiple times

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

Example: Inserting 3 new employees and their phone number

data = [
    ('Jane','555-001'),
    ('Joe', '555-001'),
    ('John', '555-003')
    ]
stmt = "INSERT INTO employees (name, phone) VALUES ('%s','%s')"
cursor.executemany(stmt, data)

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

Results are discarded. If they are needed, consider looping over
data using the execute() method.
NrK   )r.   ry   
seq_paramss      r/   executemanyCursorBase.executemany   rs   r2   c                    gaReturn next row of a query result set.

Returns:
    tuple or None: A row from query result set.
NrK   r;   s    r/   fetchoneCursorBase.fetchone  rs   r2   c                    g)  Return the next set of rows of a query result set.

When no more rows are available, it returns an empty list.
The number of rows returned can be specified using the size argument,
which defaults to one.

Returns:
    list: The next set of rows of a query result set.
NrK   )r.   sizes     r/   	fetchmanyCursorBase.fetchmany  rs   r2   c                    gqReturn all rows of a query result set.

Returns:
    list: A list of tuples with all rows of a query result set.
NrK   r;   s    r/   fetchallCursorBase.fetchall  rs   r2   c                    gzNot Implemented.NrK   r;   s    r/   nextsetCursorBase.nextset  rs   r2   c                    gr   rK   )r.   sizess     r/   setinputsizesCursorBase.setinputsizes"  rs   r2   c                    gr   rK   )r.   r   columns      r/   setoutputsizeCursorBase.setoutputsize%  rs   r2   c                    g)Reset the cursor to defaultNrK   r.   frees     r/   resetCursorBase.reset(  rs   r2   c                    U R                   $ )ac  Returns description of columns in a result

This property returns a list of tuples describing the columns in
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

Returns a list of tuples.
)rf   r;   s    r/   descriptionCursorBase.description+  s    $    r2   c                    U R                   $ )a  Returns the number of rows produced or affected

This property returns the number of rows produced by queries
such as a 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.
rg   r;   s    r/   rowcountCursorBase.rowcount?  s     ~~r2   )rf   rg   rh   r>   r?   rK   )ro   strrp   Sequence[Any]r>   r   )r>   r   )rK   F)ry   r   r,   z$Union[Sequence[Any], Dict[str, Any]]rz   rb   r>   r   )ry   r   r~   z.Sequence[Union[Sequence[Any], Dict[str, Any]]]r>   r   )r>   zOptional[Sequence[Any]])r   )r   rC   r>   List[Sequence[Any]])r>   r   )r   r   r>   r   N)r   r   r   r   r>   r   T)r   rb   r>   r   )r>   Optional[List[DescriptionType]]rB   )rD   rE   rF   rG   rH   rc   __annotations__r0   rq   ru   r{   r   r   r   r   r   r   r   r   rI   r   r   rJ   __classcell__rk   s   @r/   r`   r`      s     D$0  8:	 5 	
 
0*X	2	* ! !&  r2   r`   c                     \ rS rSrSr S$   S%S jjrS&S jrS'S jrS(S jrS)S jr	S(S	 jr
S*S
 jrS)S jr    S+S jr    S,S jrS-S jrS(S jrS.S jr    S/S jr  S0       S1S jjr      S2S jr      S3S jrS4S jr S5     S6S jjrS7S jrS8S jrS(S jrS9S jrS:S;S jjrS<S jrS$S=S jjrS>S jr\ S?S j5       r!\ S@S  j5       r"\ S)S! j5       r#SAS" jr$S#r%g)BMySQLCursoriQ  a  Default cursor for interacting with MySQL

This cursor will execute statements and handle the result. It will
not automatically fetch all rows.

MySQLCursor should be inherited whenever other functionallity is
required. An example would to change the fetch* member functions
to return dictionaries instead of lists of values.

Implements the Python Database API Specification v2.0 (PEP-249)
Nc                    [         R                  U 5        S U l        SU l        SU l        Ub  U R                  U5        g g )NNNF)r`   r0   _connection_nextrow_binary_set_connectionr.   
connections     r/   r0   MySQLCursor.__init__^  sF     	D!MQL
 #!  , "r2   c                .    [        U R                  S5      $ )zU
Iteration over the result set which calls self.fetchone()
and returns the next row.
N)iterr   r;   s    r/   __iter__MySQLCursor.__iter__l  s    
 DMM4((r2   c                     [         R                  " U5      U l        U R                  R                  5         g! [        [
        4 a    [        SS9Sef = f)zSet the connectioni   )errnoN)weakrefproxyr   is_connectedAttributeError	TypeErrorr   r   s     r/   r   MySQLCursor._set_connections  sK    	7&}}Z8D))+	* 	7 t,$6	7s	   58 Ac                    SU l         SU l        / U l        SU l        SU l        SU l        SU l        / U l        U R                  5         g)r   re   r   Nr   )	rg   r   _stored_results	_warnings_warning_countrf   	_executed_executed_listr   r;   s    r/   _reset_resultMySQLCursor._reset_result{  sG     $246:#$=A/302

r2   c                P     U R                   R                  $ ! [         a     gf = f)z'Check whether there is an unread resultF)r   unread_resultr   r;   s    r/   _have_unread_resultMySQLCursor._have_unread_result  s+    	##111 		s    
%%c                <    U R                   c  [        [        5      eg)zcCheck if the statement has been executed.

Raises an error if the statement has not been executed.
N)r   r   ERR_NO_RESULT_TO_FETCHr;   s    r/   _check_executedMySQLCursor._check_executed  s    
 >>! !788 "r2   c                l     U R                  5       nU(       d  [        eU$ ! [         a    [        Sef = f)zU
Used for iterating over the result set. Calles self.fetchone()
to get the next row.
N)r   r   StopIterationr.   rows     r/   __next__MySQLCursor.__next__  s;    
	*--/C 
	  	*T)	*s   ! 3c                    U R                   c  gU R                   R                  5         U R                  5         SU l         g)zAClose the cursor

Returns True when successful, otherwise False.
NFT)r   handle_unread_resultr   r;   s    r/   ru   MySQLCursor.close  s<    
 #--/r2   c                   0 n U R                   R                  nU R                   R                  R                  nU R                   R                  R                  nU R                   R                  R
                  nUR                  5        HF  u  pxUn	U" U	5      n	U" X5      n	[        U[        5      (       d  U" U	5      n	XUR                  5       '   MH     U$ ! [         a  n
[        SU
 35      U
eSn
A
ff = f)z,Process query parameters given as dictionaryz'Failed processing pyformat-parameters; N)r   sql_mode	converterto_mysqlescapequoteitems
isinstancer   encode	Exceptionr   )r.   r,   resr   r   r   r   rV   rT   converrs              r/   _process_params_dict MySQLCursor._process_params_dict  s     !#	''00H''11::H%%//66F$$..44E$lln
~d-!%11 ;D$(CJJL! - 
	  	"9#?	s   CC 
C4 C//C4c                D   USS n U R                   R                  nU R                   R                  R                  nU R                   R                  R                  nU R                   R                  R
                  nU Vs/ sH
  ot" U5      PM     nnU Vs/ sH
  ou" Xs5      PM     nn[        U5       VVs/ sH&  u  p[        X   [        5      (       d  U" U5      OUPM(     nnn[        U5      $ s  snf s  snf s  snnf ! [         a  n	[        SU	 35      U	eSn	A	ff = f)zProcess query parameters.Nz%Failed processing format-parameters; )r   r   r   r   r   r   	enumerater   r   r   r   tuple)
r.   r,   r   r   r   r   r   rT   ir   s
             r/   _process_paramsMySQLCursor._process_params  s    Qi	''00H''11::H%%//66F$$..44E034u8E?C48;<u6%*C< !*# .HA %/vy'$B$BeM .   Sz 5<  	"7u=	sB   A:D C1D C6'D 7,C;#D 1D 
DDDc                     US   U l         US   U l        US   U l        U R                  5         g! [        [        4 a  n[        SU 35      SeSnAff = f)z7Handles result of execute() when there is no result setaffected_rows	insert_idwarning_countzFailed handling non-resultset; N)rg   _last_insert_idr   KeyErrorr   r   _handle_warnings)r.   r   r   s      r/   _handle_noresultsetMySQLCursor._handle_noresultset  sk    	V 1DN#&{#3D "%o"6D 	 )$ 	V"%DSE#JKQUU	Vs   1 AAAc                    g)zHandles result set

This method handles the result set and is called after reading
and storing column information in _handle_result(). For non-buffering
cursors, this method is usually doing nothing.
NrK   r;   s    r/   _handle_resultsetMySQLCursor._handle_resultset  rs   r2   c                   [        U[        5      (       d  [        S5      eSU;   a,  US   U l        SU R                  l        U R                  5         gSU;   a#  SU R                  l        U R                  U5        g[        S5      e)z
Handle the result after a command was send. The result can be either
an OK-packet or a dictionary containing column/eof information.

Raises InterfaceError when result is not a dict() or result is
invalid.
zResult was not a dict()columnsTr   FzInvalid resultN)r   dictr   rf   r   r   r  r   r.   results     r/   _handle_resultMySQLCursor._handle_result  s|     &$'' !:;; &y 1D-1D*""$&-2D*$$V, !122r2   c              #  B  #    [         R                  U R                  5      nSn  [        U5      nU R	                  5         U R                  U5         X#   R                  5       U l        US-  nU v   MP  ! [         a    US   U l         Nf = f! [         a     gf = f7f)a/  Generator returns MySQLCursor objects for multiple statements

This method is only used when multiple statements are executed
by the execute() method. It uses zip() to make an iterator from the
given query_iter (result of MySQLConnection.cmd_query_iter()) and
the list of statements that were executed.
r   r   N)	RE_SQL_SPLIT_STMTSsplitr   nextr   r
  stripr5   r   )r.   
query_iterexecuted_listr   r	  s        r/   _execute_iterMySQLCursor._execute_iter  s      +00@j)""$##F+6%2%5%;%;%=DNFA 
  " 6%21%5DN6 ! sL   #B,B A5 /B 3B5B	B BB 
BBBBc                   U(       d  g U R                   (       d  [        e U R                   R                  5         U R	                  5         Sn [        U[        [        45      (       d&  UR                  U R                   R                  5      nOUn U(       a  [        U[        5      (       a  [        XPR                  U5      5      nO[        U[         ["        45      (       aK  [%        U R'                  U5      5      n[(        R+                  Xe5      nUR,                  S:w  a  [        S5      eO%[        S[/        U5      R0                   SU S35      eXPl        U(       a1  / U l        U R7                  U R                   R9                  U5      5      $  U R;                  U R                   R=                  U5      5        g! [        [        4 a  n[        S5      UeSnAff = f! [        [        4 a  n[        [        U5      5      UeSnAff = f! [>         a-  nU R                   R@                  (       a  [?        S	5      Uee SnAff = f)
rx   NzCursor is not connected r   1Not all parameters were used in the SQL statementzCould not process parameters: r&   z)), it must be of type list, tuple or dictz1Use multi=True when executing multiple statements)!r   r   ReferenceErrorr   r   r   r4   	bytearrayr   python_charsetUnicodeDecodeErrorUnicodeEncodeErrorr   r  r^   r   listr   r(   r   RE_PY_PARAMr[   r<   typerD   r   r   r  cmd_query_iterr
  	cmd_queryr   have_next_result)r.   ry   r,   rz   r   r]   psubs          r/   r{   MySQLCursor.execute$  s   . 	G##&& $
 	--/	6i%);<< ''(8(8(G(GH  &$''+D2K2KF2STFT5M22()=)=f)EF"t2>>Q&*K  '
 '4T&\5J5J4K1VH U> > 
 "$D%%d&6&6&E&Ed&KLL	 0 0 : :4 @A [ !.1 	G"#<=3F	G #$67 	6"3s8,#5	64  	00$G 	sN   F? A G# G# *H ?G GG #H3HH
I(IIc           	        S
S jn[         R                  " [        S[         R                  " [        X15      5      n[         R                  " [
        U5      nU(       d  [        S5      eUR                  S5      R                  U R                  R                  5      n/ n UR                  U R                  R                  5      nU H  n	Un[        U	[        5      (       a  [        X@R                  U	5      5      nOJ[        U R!                  U	5      5      n
["        R                  X5      nU
R$                  S:w  a  ['        S5      eUR)                  U5        M     Xh;   a*  UR+                  USR-                  U5      S5      nXl        U$ g! [0        [2        4 a  n['        [5        U5      5      UeSnAf[6         a    e [8         a  n[        S	U 35      SeSnAff = f)zImplements multi row insertc                R    U R                  S5      (       a  gU R                  S5      $ )zRemove comments from INSERT statements.

This function is used while removing comments from INSERT
statements. If the matched string is a comment not enclosed
by quotes, it returns an empty string, else the string itself.
r   r     )group)matchs    r/   remove_comments2MySQLCursor._batch_insert.<locals>.remove_commentsu  s"     {{1~~;;q>!r2   r  zAFailed rewriting statement for multi-row INSERT. Check SQL syntaxr   r   r     ,N Failed executing the operation; )r)  rA   r>   r   )rer[   RE_SQL_ON_DUPLICATERE_SQL_COMMENTsearchRE_SQL_INSERT_VALUESr   r(  r   r   r  r   r  r^   r   r(   r   r  r<   r   appendrX   joinr   r  r  r   r   r   )r.   ry   r~   r*  tmpmatchesfmtvaluesr]   r,   r#  r   s               r/   _batch_insertMySQLCursor._batch_insertp  s   
		" ffFF>?>
 ))0#6 S  mmA%%d&6&6&E&EF	U##D$4$4$C$CDD$fd++.s4M4Mf4UVC,T-A-A&-IJD%//$4C~~*.O  c" % {||C6):A>!%"$67 	6"3s8,#5 	 	U #CC5!IJPTT	Us%   C)F
 
GF//GGGc                z   U(       a  U(       d  gU R                   R                  5          [        U5      n[
        R                  " [        U5      (       a:  U(       d  SU l        gU R                  X5      nUb  XPl
        U R                  U5      $ Sn U HX  nU R                  X5        U R                  (       a%  U R                  5       (       a  U R                  5         X`R                  -  nMZ     X`l        g! [         a  n[	        S5      UeSnAff = f! [        [        4 a  n[!        SU 35      SeSnAff = f)aN  Execute the given operation multiple times

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

Example: Inserting 3 new employees and their phone number

data = [
    ('Jane','555-001'),
    ('Joe', '555-001'),
    ('John', '555-003')
    ]
stmt = "INSERT INTO employees (name, phone) VALUES ('%s','%s)"
cursor.executemany(stmt, data)

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

Results are discarded. If they are needed, consider looping over
data using the execute() method.
Nz(Parameters for query must be an Iterabler   r-  )r   r   r   r   r   r.  r)  RE_SQL_INSERT_STMTrg   r9  r   r{   	with_rowsr   r   rS   r   )r.   ry   r~   _r   r]   rowcntr,   s           r/   r   MySQLCursor.executemany  s   0 
--/	XZ A
 88&	22!"%%i<D!%||D))	U$Y/>>d&>&>&@&@MMO..(	 %  /  	X"#MNTWW	X( I& 	U #CC5!IJPTT	Us0   C8 AD 8
DDDD:&D55D:c                ,    [        U R                  5      $ )zReturns an iterator for stored results

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

Returns a iterator.
)r   r   r;   s    r/   stored_resultsMySQLCursor.stored_results  s     D(())r2   c           	        U(       a  [        U[        5      (       d  [        S5      e[        U[        [        45      (       d  [        S5      eSn/ U l        / n / n/ nUR                  S5      S   nU(       a  / n[        U5       H  u  pUR                  XyS-   S9nUR                  U5        [        U
[        5      (       a1  UR                  SU S	U
S    S
35        UR                  U
S   5        Mn  UR                  U5        UR                  U
5        M     SR                  S U 5       5      nU R                  SU 3U5        SU SSR                  U5       S
3nU R                  R                  nU R                  R                  U5       H  nSU R                  l        [        U [        [         45      (       a  [         nO@[        U ["        [$        45      (       a  [$        nOU R&                  (       a  [(        nO[*        nU" U R                  R-                  5       5      nSU S
3Ul        UR1                  U5        UR2                  b  UR2                  U l        SU;   d  M  UR                  U5        M     XR                  l        U(       a}  [7        Xe V
s/ sH  oR9                  S5      PM     sn
5       VVs/ sH  u  nnU S	U 3PM     nnnSSR                  U5       3nU R                  U5        X@l        U R;                  5       $ X@l        [        5       $ s  sn
f s  snnf ! [<         a    e [>         a  n[A        SU 35      SeSnAff = f)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.

Coding Example:
  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, 5, 0)  # 0 is to hold pprod
  cursor.callproc('multiply', args)
  print(cursor.fetchone())

For OUT and INOUT parameters the user should provide the
type of the parameter as well. The argument should be a
tuple with first item as the value of the parameter to pass
and second argument the type of the argument.

In the above example, one can call callproc method like:
  args = (5, 5, (0, 'INT'))
  cursor.callproc('multiply', args)

The type of the argument given in the tuple will be used by
the MySQL CAST function to convert the values in the corresponding
MySQL type (See CAST in MySQL Reference for more information)

Does not return a value, but a result set will be
available when the CALL-statement execute successfully.
Raises exceptions when something is wrong.
zprocname must be a stringzargs must be a sequencez@_{name}_arg{index}.re   r   )namer-   z CAST(z AS )r   ,c              3  (   #    U H	  o S 3v   M     g7f)z=%sNrK   ).0args     r/   	<genexpr>'MySQLCursor.callproc.<locals>.<genexpr>0  s     'Hx%sx   zSET zCALL r&   Fz(a result of Nr  z@_zSELECT zFailed calling stored routine; )!r   r   rS   r   r  r   r  r   formatr3  r4  r{   r   can_consume_resultsr   MySQLCursorDictMySQLCursorBufferedDictMySQLCursorNamedTupleMySQLCursorBufferedNamedTuplerc   MySQLCursorBufferedRawMySQLCursorBufferedget_selfr   r
  warningsr   ziplstripr   r   r   r   )r.   ro   rp   argfmtresultsargnamesargtypesprocname_abs	argvaluesidxrK  argnameplaceholderscallrP  r	  cursor_classcurrF  aliasselectr   s                         r/   rq   MySQLCursor.callproc  s   P z(C88899$..677&!G	THH
 $>>#.r2L	 )$HC$mm1WmMGOOG,!#u-- &	c!fXQ(GH!((Q0 0!((- !0  #xx'Hx'HHtL>2I>8*Achhx&8%9;D #'"2"2"F"F**99$?7<  4d_6M$NOO#:L*,IJ  $ALYY#9L#6L"4#3#3#<#<#>?"/vQ 7""6*<<+%(\\DN&NN3'+ @, 4G0 (+ x"Hx::d#3x"H((e fD((   #388D>"23V$'.$}}&#* 7N #I  	 	T #B3%!HItS	TsC   H
L, (5L, L!
6
L,  L&=L, L, !L, ,M MMc                    U R                   $ )zReturns the value generated for an AUTO_INCREMENT column

Returns the value generated for an AUTO_INCREMENT column by
the previous INSERT or UPDATE statement.

Returns a long value or None.
)r   r;   s    r/   getlastrowidMySQLCursor.getlastrowide  s     ###r2   c                    / n U R                   R                  SS9nUR                  S5        UR                  5       nUR	                  5         U(       a  U$ g! [
         a  n[        SU 35      SeSnAff = f)z
Fetch warnings doing a SHOW WARNINGS. Can be called after getting
the result.

Returns a result set or None when there were no warnings.
FrawzSHOW WARNINGSzFailed getting warnings; N)r   cursorr{   r   ru   r   r   )r.   r   rf  r   s       r/   _fetch_warningsMySQLCursor._fetch_warningso  s~     	N""))e)4CKK(,,.CIIK J  	N #<SE!BCM	Ns   A
A 
A6"A11A6c                   U R                   R                  (       a&  U R                  (       a  U R                  5       U l        U R                  (       d  g[        U R                  S   S   U R                  S   S   U R                   R                  (       + S9nU R                   R                  (       a  Ue[        R                  " USS9  g)zHandle possible warnings after all results are consumed.

Raises:
    Error: Also raises exceptions if raise_on_warnings is set.
Nr   r   r'  )warning   )
stacklevel)	r   get_warningsr   rq  r   r   raise_on_warningsrX  warn)r.   r   s     r/   r   MySQLCursor._handle_warnings  s     ((T-@-@!113DN~~!NN1a NN1a ((:::
 --Ica(r2   c                h    SU R                   l        SU l        US   U l        U R	                  5         g)zHandle EOF packetFr   r   N)r   r   r   r   r   r.   eofs     r/   _handle_eofMySQLCursor._handle_eof  s0    ).&$!/2r2   c                   U R                  5       (       d  gSnU R                  S:X  a2  U R                  R                  U R                  U R
                  US9u  p#OU R                  u  p#U(       a  U R                  R                  U R                  U R
                  US9U l        U R                  S   nUb  U R                  U5        U R                  S:X  a  SU l        OU =R                  S-  sl        U(       a  U R                  U5        U$ )zAReturns the next row in the result set

Returns a tuple or None.
Nr   )binaryr  ro  r   re   )r   r   r   get_rowr   r   r~  rg   )r.   ro  r   r}  s       r/   
_fetch_rowMySQLCursor._fetch_row  s    
 ''))==L())11||T-=-=3 2 JS# JS ,,44||T-=-=3 5 DM --"C  %~~#!"!#S!
r2   c                B    U R                  5         U R                  5       $ r   r   r  r;   s    r/   r   MySQLCursor.fetchone       	  r2   c                   U R                  5         / nU=(       d    U R                  nUS:  a_  U R                  5       (       aJ  US-  nU R                  5       nU(       a  UR	                  U5        US:  a  U R                  5       (       a  MJ  U$ r   r   r   )r   rh   r   r   r3  r.   r   r   cntr   s        r/   r   MySQLCursor.fetchmany  sx     	$dnnAg$22441HC--/C

3	 Ag$2244
 
r2   c                   U R                  5         U R                  5       (       d  / $ U R                  R                  5       u  pU R                  S   (       a  UR                  SU R                  S   5        U R                  U5        [        U5      nUS:  a  U R                  S:X  a  SU l        U =R                  U-  sl        U$ )r   r   re   	r   r   r   get_rowsr   insertr~  r:   rg   r.   rowsr}  r   s       r/   r   MySQLCursor.fetchall  s     	''))I&&//1==KK4==+,t9q=T^^r1DN("r2   c                p    U R                   (       d
  [        5       $ [        S U R                    5       5      $ )z\Returns column names

This property returns the columns names as a tuple.

Returns a tuple.
c              3  (   #    U H	  oS    v   M     g7f)r   NrK   )rJ  ds     r/   rL  +MySQLCursor.column_names.<locals>.<genexpr>  s     4#3aqT#3rN  )r   r   r;   s    r/   column_namesMySQLCursor.column_names  s+     7N44#3#3444r2   c                    U R                   c  g U R                   R                  5       R                  S5      $ ! [        [        4 a    U R                   R                  5       s $ f = f)zReturns the executed statement

This property returns the executed statement. When multiple
statements were executed, the current statement in the iterator
will be returned.
Nutf-8)r   r  decoder   r  r;   s    r/   	statementMySQLCursor.statement   s\     >>!	*>>'')0099 23 	*>>''))	*s   (9 *A&%A&c                (    U R                   (       d  gg)zReturns whether the cursor could have rows returned

This property returns True when column descriptions are available
and possibly also rows, which will need to be fetched.

Returns True or False.
FT)r   r;   s    r/   r=  MySQLCursor.with_rows  s     r2   c                   SnU R                   (       a4   U R                   R                  S5      n[        U5      S:  a  US S S-   nOSnUR	                  U R
                  R                  US9$ ! [         a    U R                   n NVf = f)Nz{class_name}: {stmt}r  (   z..z(Nothing executed yet))
class_namer]   )r   r  r   r:   rO  rk   rD   )r.   r7  executeds      r/   __str__MySQLCursor.__str__  s    $>>*>>009 8}r!#CR=4//HzzT^^%<%<8zLL " *>>*s   A. .BB)r   r   rf   r   r   r   r   rg   r   r   r   r   r   'Optional[Type[MySQLConnectionAbstract]]r>   r?   )r>   zIterator[RowType])r   zType[MySQLConnectionAbstract]r>   r?   r   r>   rb   )r>   r"   )r,   r   r>   z"Dict[bytes, Union[bytes, Decimal]])r,   r    r>   z!Tuple[Union[bytes, Decimal], ...]r   r!   r>   r?   r	  r!   r>   r?   )r  z!Generator[ResultType, None, None]r>   z"Generator[MySQLCursor, None, None]NF)ry   r#   r,   "Optional[ParamsSequenceOrDictType]rz   rb   r>   ,Optional[Generator[MySQLCursor, None, None]])ry   r   r~   "Sequence[ParamsSequenceOrDictType]r>   zOptional[bytes])ry   r   r~   r  r>   r  )r>   zIterator[MySQLCursor]r   )ro   r   rp   r   r>   z8Optional[Union[Dict[str, ToPythonOutputTypes], RowType]])r>   Optional[int])r>   zOptional[List[WarningType]]r}  r   r>   r?   Fro  rb   r>   Optional[RowType]r>   r  r   r  r>   List[RowType]r>   r  )r>   zTuple[str, ...])r>   zOptional[str])r>   r   )&rD   rE   rF   rG   rH   r0   r   r   r   r   r   r   ru   r   r   r   r  r
  r  r{   r9  r   rB  rq   rk  rq  r   r~  r  r   r   r   rI   r  r  r=  r  rJ   rK   r2   r/   r   r   Q  s   
 EI-A-	-)7
9$	+.(	*,	 3.;	+> 6:	JJ 3J 	J
 
6JX6U6U*L6U	6Up55*L5	55n	* !yTyT yT 
B	yTv$*). @!(* 	5 	5 * * 
 
Mr2   r   c                     ^  \ rS rSrSr S   SU 4S jjjrSS jrSSS jjrSSS jjrSS jr	SS jr
SSS	 jjr\SS
 j5       rSrU =r$ )rV  i*  z*Cursor which fetches rows within execute()c                @   > [         TU ]  U5        S U l        SU l        g r+   )ri   r0   _rows	_next_rowr.   r   rk   s     r/   r0   MySQLCursorBuffered.__init__-  s      	$.2
r2   c                    U R                   R                  5       u  U l        n[        U R                  5      U l        U R                  U5        SU l         SU R                   l        g ! [         a     g f = f)Nr   F)	r   r  r  r:   rg   r~  r  r   r   r|  s     r/   r  %MySQLCursorBuffered._handle_resultset4  sf     ,,557STZZ	-2D* 		s   A( (
A54A5c                    S U l         g r   r  r   s     r/   r   MySQLCursorBuffered.reset>  s	    
r2   c                    S n U R                   U R                     nU =R                  S-  sl        U$ ! [        [        4 a     g f = f)Nr   )r  r  r5   r   )r.   ro  r   s      r/   r  MySQLCursorBuffered._fetch_rowA  sL    	**T^^,C 	!
 I& 		s   4 AAc                B    U R                  5         U R                  5       $ r  r  r;   s    r/   r   MySQLCursorBuffered.fetchoneJ  r  r2   c                    U R                   b  U R                  c  [        [        5      e/ nU R                  U R                  S n[        U R                  5      U l        U$ r   )r   r  r   r   r  r:   )r.   r   s     r/   r   MySQLCursorBuffered.fetchallS  sQ     >>!TZZ%7 !788jj)*TZZ
r2   c                    U R                  5         / nU=(       d    U R                  nUS:  a5  US-  nU R                  5       nU(       a  UR                  U5        US:  a  M5  U$ r  )r   rh   r   r3  r  s        r/   r   MySQLCursorBuffered.fetchmany`  s\     	$dnnAg1HC--/C

3	 Ag 
r2   c                    U R                   S L$ r   r  r;   s    r/   r=  MySQLCursorBuffered.with_rowsu      zz%%r2   r  rg   r  r   r  r   r   r   rb   r>   r?   r  r  r  r  r  r  )rD   rE   rF   rG   rH   r0   r  r   r  r   r   r   rI   r=  rJ   r   r   s   @r/   rV  rV  *  sY    4 EI A 	   !* & &r2   rV  c                  <    \ rS rSr% SrSrS\S'   S
S jrSS jrSr	g	)MySQLCursorRawiz  zK
Skips conversion from MySQL datatypes to Python types when fetching rows.
Trb   rc   c                @    U R                  5         U R                  SS9$ )r   Trn  r  r;   s    r/   r   MySQLCursorRaw.fetchone  s!     	4((r2   c                   U R                  5         U R                  5       (       d  / $ U R                  R                  SS9u  pU R                  S   (       a  UR                  SU R                  S   5        U R                  U5        [        U5      nUS:  a  U R                  S:X  a  SU l        U =R                  U-  sl        U$ )r   Trn  r   re   r  r  s       r/   r   MySQLCursorRaw.fetchall  s     	''))I&&//D/9==KK4==+,t9q=T^^r1DN("r2   r   Nr  r  )
rD   rE   rF   rG   rH   rc   r   r   r   rJ   rK   r2   r/   r  r  z  s     D$)r2   r  c                  Z    \ rS rSr% SrSrS\S'   SS jrSS jrSS jr	\
SS	 j5       rS
rg)rU  i  zz
Cursor which skips conversion from MySQL datatypes to Python types when
fetching rows and fetches rows within execute().
Trb   rc   c                   U R                   R                  U R                  S9u  U l        n[	        U R                  5      U l        U R                  U5        SU l         SU R                   l        g ! [         a     g f = f)Nrn  r   F)
r   r  rc   r  r:   rg   r~  r  r   r   r|  s     r/   r  (MySQLCursorBufferedRaw._handle_resultset  so     ,,55$))5DSTZZ	-2D* 		s   A1 1
A>=A>c                B    U R                  5         U R                  5       $ r  r  r;   s    r/   r   MySQLCursorBufferedRaw.fetchone  r  r2   c                f    U R                  5         [        U R                  U R                  S 5      $ r   )r   r  r  r  r;   s    r/   r   MySQLCursorBufferedRaw.fetchall  s+     	DJJt~~/011r2   c                    U R                   S L$ r   r  r;   s    r/   r=   MySQLCursorBufferedRaw.with_rows  r  r2   r  Nr   r  r  r  )rD   rE   rF   rG   rH   rc   r   r  r   r   rI   r=  rJ   rK   r2   r/   rU  rU    s6    
 D$!2 & &r2   rU  c                     ^  \ rS rSrSrSSU 4S jjjrSSS jjrSU 4S jjrSS jrSU 4S jjr	SSS jjr
SU 4S	 jjrSSS
 jjrSS jr  S       SS jjr      S S jrS!S jrSS"S jjrS#S jrSrU =r$ )$MySQLCursorPreparedi  z&Cursor using MySQL Prepared Statementsc                   > [         TU ]  U5        S U l        SU l        S U l        SU l        S U l        SU l        SU l        g )Nr   TF)	ri   r0   r  r  	_preparedr   _have_result_last_row_sent_cursor_existsr  s     r/   r0   MySQLCursorPrepared.__init__  sD    $.2
QU!,0$)$)r2   c                    U R                   (       a0   U R                  R                  U R                   S   5        S U l         SU l        SU l        g ! [         a     N"f = f)Nstatement_idF)r  r   cmd_stmt_closer   r  r  r   s     r/   r   MySQLCursorPrepared.reset  sX    >>  //~0NO "DN##  s   (A 
AAc           	        > U R                  UR                  SUR                  SS5      5      5        [        TU ]  U5        g Nstatus_flagserver_statusr   )_handle_server_statusgetri   r   )r.   r   rk   s     r/   r   'MySQLCursorPrepared._handle_noresultset  s5    ""377=#''/ST:U#VW#C(r2   c                p    U[         R                  -  S:g  U l        U[         R                  -  S:g  U l        g)z_Check for SERVER_STATUS_CURSOR_EXISTS and
SERVER_STATUS_LAST_ROW_SENT flags set by the server.
r   N)r   STATUS_CURSOR_EXISTSr  STATUS_LAST_ROW_SENTr  )r.   flagss     r/   r  )MySQLCursorPrepared._handle_server_status  s4     $j&E&EEJ#j&E&EEJr2   c           	        > U R                  UR                  SUR                  SS5      5      5        [        TU ]  U5        g r  )r  r  ri   r~  )r.   r}  rk   s     r/   r~  MySQLCursorPrepared._handle_eof  s5    ""377=#''/ST:U#VWC r2   c                    [        5       e)zACalls a stored procedue

Not supported with MySQLCursorPrepared.
)r   rn   s      r/   rq   MySQLCursorPrepared.callproc  s    
  !!r2   c                B   > U R                  5         [        TU ]	  5         g)zbClose the cursor

This method will try to deallocate the prepared statement and close
the cursor.
N)r   ri   ru   rj   s    r/   ru   MySQLCursorPrepared.close  s     	

r2   c                    g)zvConvert row data from MySQL to Python types

The conversion is done while reading binary data in the
protocol module.
NrK   r.   rowdatadescs      r/   _row_to_python"MySQLCursorPrepared._row_to_python  rs   r2   c                J   [        U[        5      (       a*  SU R                  l        SU l        U R                  U5        gUS   U l        SU R                  l        SU l        SUS   ;   a  U R                  US   S   5        gSUS   ;   a  U R                  US   S   5        gg)zHandle result after executionFr   Tr  r'  r  N)r   r  r   r   r  r   rf   r  r  s     r/   r
  "MySQLCursorPrepared._handle_result  s    fd##-2D* %D$$V, &q	D-1D* $Dq	)**6!9]+CD F1I-**6!9_+EF .r2   c                  ^ U R                   R                  nUS:X  a  Sn[        U[        5      (       d   UR	                  U5      n[        T[        5      (       aM  [        R                  " [        U5      n [        U4S jU 5       5      m[        R                  " [        SU5      nXR                  La  U R                   (       a(  U R                   R#                  U R                   S   5        Xl         UR%                  U5      nSU;   a  [        R                  " [(        S	U5      n U R                   R+                  U5      U l        U R                   R/                  U R                   S   5        U R                   S
   (       a  T(       d  gT(       an  [        T[        [0        45      (       d$  [        SS[3        T5      R4                   ST S3S9e[7        U R                   S
   5      [7        T5      :w  a
  [        SSS9eTc  SmU R                   R9                  U R                   S   TU R                   S
   S9nU R;                  U5        g! [
         a  n[        [        U5      5      UeSnAff = f! [         a  n[        S5      UeSnAff = f! [&         a  n[        [        U5      5      UeSnAff = f! [,         a	    SU l        e f = f)a  Prepare and execute a MySQL Prepared Statement

This method will prepare the given operation and execute it using
the optionally given parameters.

If the cursor instance already had a prepared statement, it is
first closed.

Note: argument "multi" is unused.
utf8mb4utf8Nc              3  ,   >#    U H
  nTU   v   M     g 7fr   rK   )rJ  rV   r,   s     r/   rL  .MySQLCursorPrepared.execute.<locals>.<genexpr>3  s     G6Fsvc{6Fs   z6Not all placeholders were found in the parameters dict?r  s   %s   ?
parametersi  zIncorrect type of argument: r&   zP), it must be of type tuple or list the argument given to the prepared statement)r   msgz:Incorrect number of arguments executing prepared statementrK   )datar  )r   charsetr   r   r  r  r   r  r.  findall RE_SQL_PYTHON_CAPTURE_PARAM_NAMEr   r   r[   RE_SQL_PYTHON_REPLACE_PARAMr   r  r  r   r  RE_SQL_FIND_PARAMcmd_stmt_preparer   cmd_stmt_resetr  r  rD   r:   cmd_stmt_executer
  )r.   ry   r,   rz   r  r   replacement_keysr   s     `     r/   r{   MySQLCursorPrepared.execute  s     ""**iG)S)):%,,W5	 fd##!zz*JIVG6FGG :CKINN*~~  //~0NO&N:%,,W5	 	!FF#4dIF	!%!1!1!B!B9!M
 	''~(FG>>,'fudm44&6tF|7L7L6MQvh W- -  4>>,/0CK?&T 
 >F//NN>*~~l3 0 

 	C y & :&s3x0c9:  &L & :&s3x0c9:  !%sS   I 8I7 7J + J< 
I4I//I47
JJJ
J9J44J9<Kc                    Sn U HX  nU R                  X5        U R                  (       a%  U R                  5       (       a  U R                  5         X0R                  -  nMZ     X0l        g! [
        [        4 a  n[        SU 35      SeSnAff = f)a  Prepare and execute a MySQL Prepared Statement many times

This method will prepare the given operation and execute with each
tuple found the list seq_params.

If the cursor instance already had a prepared statement, it is
first closed.

executemany() simply calls execute().
r   r-  N)r{   r=  r   r   rg   rS   r   r   )r.   ry   r~   r?  r,   r   s         r/   r   MySQLCursorPrepared.executemanyj  s     	U$Y/>>d&>&>&@&@MMO..(	 %   I& 	U #CC5!IJPTT	Us   AA) )B9BBc                    U R                  5         U R                  (       a(  U R                  R                  U R                  S   5        U R                  5       =(       d    S$ )r   r  N)r   r  r   cmd_stmt_fetchr  r  r;   s    r/   r   MySQLCursorPrepared.fetchone  sH     	++DNN>,JK (D(r2   c                   U R                  5         / nU=(       d    U R                  nUS:  a_  U R                  5       (       aJ  US-  nU R                  5       nU(       a  UR	                  U5        US:  a  U R                  5       (       a  MJ  U$ r  )r   rh   r   r  r3  r  s        r/   r   MySQLCursorPrepared.fetchmany  sy     	$dnnAg$22441HC//#C

3	 Ag$2244
 
r2   c                &   U R                  5         / nU R                  S   (       a  UR                  U R                  S   5        U R                  5       (       a  U R                  (       a-  U R
                  R                  U R                  S   [        5        U R
                  R                  U R                  U R                  S9u  p#UR                  U5        U R                  U5        U R                  5       (       a  M  [        U5      U l        U$ )r   r   r  )r  r  )r   r   r3  r   r  r   r  r  MAX_RESULTSr  r   r   extendr~  r:   rg   r.   r  r5  r}  s       r/   r   MySQLCursorPrepared.fetchall  s     	==KKa()&&((""  //NN>2K ))22||T-=-= 3 JS KKS! &&(( Tr2   )
r   r  rf   r   r  r  r  r  rg   r  r   )r   r  r   r  r  )r  rC   r>   r?   r  r   )ro   r   rp   r   r>   r   r   )r  r   r  r   r>   r   r  r  )ry   r#   r,   r  rz   rb   r>   r?   )ry   r   r~   zSequence[ParamsSequenceType]r>   r?   r  r  r  )rD   rE   rF   rG   rH   r0   r   r   r  r~  rq   ru   r  r
  r{   r   r   r   r   rJ   r   r   s   @r/   r  r    s    0* *	$)K!"G& 6:	S!S! 3S! 	S!
 
S!j   1  
	 4	)( r2   r  c                  Z   ^  \ rS rSrSr S     SS jjrS	U 4S jjrS
U 4S jjrSrU =r	$ )rQ  i  z
Cursor fetching rows as dictionaries.

The fetch methods of this class will return dictionaries instead of tuples.
Each row is a dictionary that looks like:
    row = {
        "col1": value1,
        "col2": value2
    }
c                R    U(       a  [        [        U R                  U5      5      $ S$ )zGConvert a MySQL text result row to Python types

Returns a dictionary.
N)r  rY  r  r  s      r/   r  MySQLCursorDict._row_to_python  s$     9@tC))734ITIr2   c                T   > U R                  [        TU ]	  5       U R                  5      $ )zaReturn next row of a query result set.

Returns:
    dict or None: A dict from query result set.
)r  ri   r   r   rj   s    r/   r   MySQLCursorDict.fetchone  s&     ""57#3#5t7G7GHHr2   c                   > [         TU ]  5        Vs/ sH'  nU(       d  M  U R                  XR                  5      PM)     sn$ s  snf )zReturn all rows of a query result set.

Returns:
    list: A list of dictionaries with all rows of a query
          result set where column names are used as keys.
ri   r   r  r   r.   r   rk   s     r/   r   MySQLCursorDict.fetchall  sH     w')
) 7D%5%56)
 	
 

   
AArK   r   )r  r"   r  r   r>   (Optional[Dict[str, ToPythonOutputTypes]]r>   r2  r>   z.List[Optional[Dict[str, ToPythonOutputTypes]]]
rD   rE   rF   rG   rH   r  r   r   rJ   r   r   s   @r/   rQ  rQ    sB    	 15	J	J .	J 
2		JI
 
r2   rQ  c                  Z   ^  \ rS rSrSr S     SS jjrS	U 4S jjrS
U 4S jjrSrU =r	$ )rS  i  z
Cursor fetching rows as named tuple.

The fetch methods of this class will return namedtuples instead of tuples.
Each row is returned as a namedtuple and the values can be accessed as:
row.col1, row.col2
c                    UnU(       a$  [        U R                  5      n [        U   nU" U6 $ g! [         a    [	        SU5      nU[        U'    N'f = f)zHConvert a MySQL text result row to Python types

Returns a named tuple.
RowN)r   r  r   r   r   )r.   r  r  r   r  named_tuples         r/   r  $MySQLCursorNamedTuple._row_to_python  sc     D--.G9/8 $$	  9(8-8!'*9s   	/ AAc                   > [         TU ]  5       nU(       d  g[        U R                  S5      (       a  U R	                  XR
                  5      $ U$ )r   Nr   )ri   r   hasattrr   r  r   r/  s     r/   r   MySQLCursorNamedTuple.fetchone  sR     g  t''55 %5%56	
 	
r2   c                   > [         TU ]  5        Vs/ sH'  nU(       d  M  U R                  XR                  5      PM)     sn$ s  snf )r   r.  r/  s     r/   r   MySQLCursorNamedTuple.fetchall  sH     w')
) 7D%5%56)
 	
 
r1  rK   r   )r  r"   r  r   r>   r  r  r>   zList[Optional[RowType]]r5  r   s   @r/   rS  rS    s=     15 . 
	*


 

r2   rS  c                  ,    \ rS rSrSrSS jrSS jrSrg)	rR  i"  z0
Buffered Cursor fetching rows as dictionaries.
c                    U R                  5         U R                  5       nU(       a  U R                  XR                  5      $ gr   r   r  r  r   r   s     r/   r    MySQLCursorBufferedDict.fetchone'  9     	oo&&s,<,<==r2   c                $   U R                   b  U R                  c  [        [        5      e/ nU R                  U R                  S  H-  nUR                  U R                  X R                  5      5        M/     [        U R                  5      U l        U$ r   	r   r  r   r   r  r3  r  r   r:   r.   r   r   s      r/   r    MySQLCursorBufferedDict.fetchall3  s     >>!TZZ%7 !788::dnn./CJJt**30@0@AB 0TZZ
r2   r  Nr3  r4  rD   rE   rF   rG   rH   r   r   rJ   rK   r2   r/   rR  rR  "      
r2   rR  c                  ,    \ rS rSrSrSS jrSS jrSrg)	rT  iB  z/
Buffered Cursor fetching rows as named tuple.
c                    U R                  5         U R                  5       nU(       a  U R                  XR                  5      $ gr   rC  r   s     r/   r   &MySQLCursorBufferedNamedTuple.fetchoneG  rE  r2   c                $   U R                   b  U R                  c  [        [        5      e/ nU R                  U R                  S  H-  nUR                  U R                  X R                  5      5        M/     [        U R                  5      U l        U$ r   rG  rH  s      r/   r   &MySQLCursorBufferedNamedTuple.fetchallS  rJ  r2   rK  Nr  r@  rL  rK   r2   r/   rT  rT  B  rM  r2   rT  c                  <   ^  \ rS rSrSr S   SU 4S jjjrSrU =r$ )MySQLCursorPreparedDictib  a  
This class is a blend of features from MySQLCursorDict and MySQLCursorPrepared

Multiple inheritance in python is allowed but care must be taken
when assuming methods resolution. In the case of multiple
inheritance, a given attribute is first searched in the current
class if it's not found then it's searched in the parent classes.
The parent classes are searched in a left-right fashion and each
class is searched once.
Based on python's attribute resolution, in this case, attributes
are searched as follows:
1. MySQLCursorPreparedDict (current class)
2. MySQLCursorDict (left parent class)
3. MySQLCursorPrepared (right parent class)
4. MySQLCursor (base class)
c                   > [         TU ]  US9 Vs/ sH'  nU(       d  M  U R                  X R                  5      PM)     sn$ s  snf )a`  Return the next set of rows of a query result set.

When no more rows are available, it returns an empty list.
The number of rows returned can be specified using the size argument,
which defaults to one.

Returns:
    list: The next set of rows of a query result set represented
          as a list of dictionaries where column names are used as keys.
r   ri   r   r  r   r.   r   r   rk   s      r/   r   !MySQLCursorPreparedDict.fetchmanyt  sM     w(d(3
3 7D%5%563
 	
 

   
AArK   r   )r   r  r>   z$List[Dict[str, ToPythonOutputTypes]]rD   rE   rF   rG   rH   r   rJ   r   r   s   @r/   rT  rT  b  s'    $ %)
!
	-
 
r2   rT  c                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )MySQLCursorPreparedNamedTuplei  zV
This class is a blend of features from MySQLCursorNamedTuple and MySQLCursorPrepared
c                   > [         TU ]  US9 Vs/ sH'  nU(       d  M  U R                  X R                  5      PM)     sn$ s  snf )aa  Return the next set of rows of a query result set.

When no more rows are available, it returns an empty list.
The number of rows returned can be specified using the size argument,
which defaults to one.

Returns:
    list: The next set of rows of a query result set represented
          as a list of named tuples where column names are used as names.
rV  rW  rX  s      r/   r   'MySQLCursorPreparedNamedTuple.fetchmany  sM     w(d(3
3 7D%5%563
 	
 
rZ  rK   r   r  r[  r   s   @r/   r]  r]    s    
 
r2   r]  c                  J    \ rS rSr% SrSrS\S'   SS jrSSS jjrSS	 jr	S
r
g)MySQLCursorPreparedRawi  zO
This class is a blend of features from MySQLCursorRaw and MySQLCursorPrepared
Trb   rc   c                    U R                  5         U R                  (       a(  U R                  R                  U R                  S   5        U R                  U R                  S9=(       d    S$ )r   r  rn  N)r   r  r   r  r  r  rc   r;   s    r/   r   MySQLCursorPreparedRaw.fetchone  sP     	++DNN>,JK499-55r2   Nc                0   U R                  5         / nU=(       d    U R                  nUS:  ah  U R                  5       (       aS  US-  nU R                  U R                  S9nU(       a  UR                  U5        US:  a  U R                  5       (       a  MS  U$ )r   r   r   rn  )r   rh   r   r  rc   r3  r  s        r/   r    MySQLCursorPreparedRaw.fetchmany  s     	$dnnAg$22441HC//dii/0C

3	 Ag$2244
 
r2   c                <   U R                  5         / nU R                  S   (       a  UR                  U R                  S   5        U R                  5       (       a  U R                  (       a-  U R
                  R                  U R                  S   [        5        U R
                  R                  U R                  U R                  U R                  S9u  p#UR                  U5        U R                  U5        U R                  5       (       a  M  [        U5      U l        U$ )r   r   r  )ro  r  r  )r   r   r3  r   r  r   r  r  r$  r  rc   r   r   r%  r~  r:   rg   r&  s       r/   r   MySQLCursorPreparedRaw.fetchall  s     	==KKa()&&((""  //NN>2K ))22IIdllD<L<L 3 JS KKS! &&(( Tr2   r   r  r   r  r  )rD   rE   rF   rG   rH   rc   r   r   r   r   rJ   rK   r2   r/   ra  ra    s"     D$	6(r2   ra  )r\   r4   rW   zDict[bytes, bytes]r>   r4   )OrH   
__future__r   r.  rX  r   collectionsr   decimalr   typingr   r   r   r	   r
   r   r   r   r   r   r   r   	abstractsr   r   r   	constantsr   errorsr   r   r   r   r   typesr   r   r   r   r    r!   r"   r#   r$   r%   SQL_COMMENTcompileIMSr0  r/  r<  r2  r  XrZ   r  r  r  r  r   r$  r(   r^   r`   r   rV  r  rU  r  rQ  rS  rR  rT  rT  r]  ra  rK   r2   r/   <module>rv     sv  >  " 	   "     & V V !    	
;-(_GDD244K"$$ jjGDD244K"$$  ZZ\+ /# # DD244K"$$	  zz":BDD244K"$$<NO jj!jj
 DD  ZZ LM JJQR  jj6 #%::n#=  6 - -2@e$ ePVM* VMrM&+ M&`![ !H&&0 &&Rq+ qh*
k *
Z7
K 7
to/B @$9;N @#
o/B #
L
$9;N 
.;0 ;r2   