Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/pymysql/__pycache__/cursors.cpython-311.pyc



]j@ddlZddlZddlmZejdejejzZGddZGddZ	Gd	d
e	eZ
GddeZGd
de	eZdS)N)errz|\s*((?:INSERT|REPLACE)\b.+\bVALUES?\s*)(\(\s*(?:%s|%\(.+\)s)\s*(?:,\s*(?:%s|%\(.+\)s)\s*)*\))(\s*(?:ON DUPLICATE.*)?);?\s*\ZceZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
d"d
ZdZdZd#dZd#dZdZdZd$dZdZd#dZdZd%dZdZdZdZdZd Zd!ZdS)&Cursora
    This is the object used to interact with the database.

    Do not create an instance of a Cursor yourself. Call
    connections.Connection.cursor().

    See `Cursor <https://www.python.org/dev/peps/pep-0249/#cursor-objects>`_ in
    the specification.
    ic||_d|_d|_d|_d|_d|_d|_d|_d|_dS)Nrr)	
connection
warning_countdescription	rownumberrowcount	arraysize	_executed_result_rows)selfr	s  F/opt/imunify360/venv/lib64/python3.11/site-packages/pymysql/cursors.py__init__zCursor.__init__"sG$



c|j}|dS	|r	|d|_dS#d|_wxYw)zD
        Closing a cursor just exhausts all remaining data.
        N)r	nextsetrconns  rclosezCursor.close-s_<F	#,,..
,,..
#DOOOdDO""""s	)?	Ac|SNrs r	__enter__zCursor.__enter__:rc0~|dSr)r)rexc_infos  r__exit__zCursor.__exit__=s

rcF|jstjd|jS)Nz
Cursor closed)r	rProgrammingErrorrs r_get_dbzCursor._get_dbAs%	8&777rc<|jstjddS)Nzexecute() first)rrr%rs r_check_executedzCursor._check_executedFs(~	:&'8999	:	:rc|Srrrrows  r	_conv_rowzCursor._conv_rowJ
rcdSz!Does nothing, required by DB API.Nrrargss  r
setinputsizeszCursor.setinputsizesMrcdSr/rr0s  rsetoutputsizeszCursor.setoutputsizesPr3rFc|}|j}|	||jurdS|jsdSd|_||||dS)zGet the next query set.N
unbufferedT)r&rhas_next
_clear_resultnext_result_do_get_result)rr8rcurrent_results    r_nextsetzCursor._nextsetSs||~~!^4<%G%G4&	4J///trc,|dS)NFr>rs rrzCursor.nextsetas}}U###rct|ttfrtfd|DSt|tr fd|DS|S)Nc3BK|]}|VdSrliteral).0argrs  r	<genexpr>z&Cursor._escape_args.<locals>.<genexpr>fs/;;sc**;;;;;;rcBi|]\}}||SrrC)rEkeyvalrs   r
<dictcomp>z'Cursor._escape_args.<locals>.<dictcomp>hs+JJJzSCc**JJJr)
isinstancetuplelistdictitemsescape)rr1rs  `r_escape_argszCursor._escape_argsdsdUDM**	%;;;;d;;;;;;
d
#
#	%JJJJTZZ\\JJJJ;;t$$$rNcd|}|||||z}|S)a
        Returns the exact string that would be sent to the database by calling the
        execute() method.

        :param query: Query to mogrify.
        :type query: str

        :param args: Parameters used with query. (optional)
        :type args: tuple, list or dict

        :return: The query with argument binding applied.
        :rtype: str

        This method follows the extension to the DB API 2.0 followed by Psycopg.
        )r&rR)rqueryr1rs    rmogrifyzCursor.mogrifyns6 ||~~D--dD999Erc|r	||||}||}||_|S)aExecute a query.

        :param query: Query to execute.
        :type query: str

        :param args: Parameters used with query. (optional)
        :type args: tuple, list or dict

        :return: Number of affected rows.
        :rtype: int

        If args is a list or tuple, %s can be used as a placeholder in the query.
        If args is a dict, %(name)s can be used as a placeholder in the query.
        )rrU_queryr)rrTr1results    rexecutezCursor.executes[llnn	llnn	UD))U##
rc	|sdSt}|r|ddz}|d}|dpd}|ddkr|d	d
ksJ||||jjStfd|D_	j	S)aRun several data against one query.

        :param query: Query to execute.
        :type query: str

        :param args: Sequence of sequences or mappings. It is used as parameter.
        :type args: tuple or list

        :return: Number of rows affected, if any.
        :rtype: int or None

        This method improves performance on multiple-row INSERT and
        REPLACE. Otherwise it is equivalent to looping over args with
        execute().
        Nrrr(r)c3DK|]}|VdSr)rY)rErFrTrs  rrGz%Cursor.executemany.<locals>.<genexpr>s1EEDLL44EEEEEEr)
RE_INSERT_VALUESmatchgrouprstrip_do_execute_manymax_stmt_lengthr&encodingsumr
)rrTr1mq_prefixq_values	q_postfixs``     rexecutemanyzCursor.executemanys 	F""5))	wwqzzBHwwqzz((**H

(bIA;#%%(2,#*=*=*==(($'

EEEEEEEEEE
}rcT|}|j}t|tr||}t|tr||}t|}	t
|}||t||z}
t|
tr|
|d}
|	|
z
}	d}|D]}||||z}
t|
tr|
|d}
t|	t|
zt|zdz|kr+||	|	|zz
}t|}	n|	dz
}	|	|
z
}	||	|	|zz
}||_
|S)Nsurrogateescaperr,)r&rRrLstrencode	bytearrayiternextlenrYr
)
rprefixvaluespostfixr1rfrgrrQsqlvrowsrFs
             rrezCursor._do_execute_manys||~~"fc""	-]]8,,Fgs##	/nnX..GDzzVVDJJ---a	6#455Aq				CT***A!S!!
:HHX'8993xx#a&& 3w<</!3oEES7]333''t1HCCS7]+++
rrc||r_dd|ddfdt|Dz|ddfdt
t|D}||||_|S)abExecute stored procedure procname with args.

        :param procname: Name of procedure to execute on server.
        :type procname: str

        :param args: Sequence of parameters to use with procedure.
        :type args: tuple or list

        Returns the original args.

        Compatibility warning: PEP-249 specifies that any modified
        parameters must be returned. This is currently impossible
        as they are only available by storing them in a server
        variable and then retrieved by a query. Since stored
        procedures return zero or more result sets, there is no
        reliable way to get at OUT or INOUT parameters via callproc.
        The server variables are named @_procname_n, where procname
        is the parameter above and n is the position of the parameter
        (from zero). Once all result sets generated by the procedure
        have been fetched, you can issue a SELECT @_procname_0, ...
        query using .execute() to get any OUT or INOUT values.

        Compatibility warning: The act of calling a stored procedure
        itself creates an empty result set. This appears after any
        result sets generated by the procedure. This is non-standard
        behavior with respect to the DB-API. Be sure to use nextset()
        to advance through all result sets; otherwise you may get
        disconnected.
        z@_z_%d=%szSET %s,c3RK|]!\}}||fzV"dSr)rQ)rEindexrFrfmts   rrGz"Cursor.callproc.<locals>.<genexpr>sN8BsC5$++c"2"233rzCALL {}({})cg|]	}d|fz
S)z@_%s_%dr)rEiprocnames  r
<listcomp>z#Cursor.callproc.<locals>.<listcomp>s"JJJAi8Q-/JJJr)	r&rWjoin	enumeraterformatrangervr)rrr1qrrs `  @@rcallproczCursor.callprocs<||~~	'x'''CKK((FOPToo



LLNNN  HHJJJJs4yy9I9IJJJKK

	
Arc||j|jt|jkrdS|j|j}|xjdz
c_|S)zFetch the next row.Nrr(rrrvrrXs  rfetchonezCursor.fetchonesX:3tz??!B!B4DN+!
rc||jdS|j|p|jz}|j|j|}t	|t|j|_|S)zFetch several rows.Nr)r(rrrminrv)rsizeendrXs    r	fetchmanyzCursor.fetchmanysg:2n 67DNS01S#dj//22
rc||jgS|jr|j|jd}n|j}t|j|_|S)zFetch all the rows.Nrrs  rfetchallzCursor.fetchall&s\:I>	 Z 0 01FFZFTZ
rrelativec||dkr|j|z}n |dkr|}ntjd|zd|cxkrt	|jksnt
d||_dS)Nrabsoluteunknown scroll mode %srzout of range)r(rrr%rvr
IndexError)rvaluemoders    rscrollz
Cursor.scroll2s:&AA
Z

AA&'?$'FGGGQ((((TZ((((^,,,rc|}|||||jSrr&r:rTr<r
rrrs   rrWz
Cursor._query?sJ||~~

1


}rchd|_d|_d|_d|_d|_d|_d|_dS)Nr)rrr
r
r	lastrowidrrs rr:zCursor._clear_resultFs9



rc|}|jx|_}|j|_|j|_|j|_|j|_|j|_	dSr)
r&r
affected_rowsr
r
r	insert_idrr|r)rrrXs   rr<zCursor._do_get_resultPsT||~~ $,v,
#1!-)[


rc|Srrrs r__iter__zCursor.__iter__[r rc@|}|t|Sr)r
StopIterationr*s  r__next__zCursor.__next__^smmoo;
rc|dvr1tjdtdtt|St|)N)
WarningErrorInterfaceError
DatabaseError	DataErrorOperationalErrorIntegrityError
InternalErrorr%NotSupportedErrorz7PyMySQL errors hould be accessed from `pymysql` packager[)
stacklevel)warningswarnDeprecationWarninggetattrrAttributeError)rnames  r__getattr__zCursor.__getattr__dsZ



MI"




3%%%T"""r)Fr)rr) __name__
__module____qualname____doc__rfrrrr#r&r(r,r2r5r>rrRrUrYrmrerrrrrrWr:r<rrrrrrrrsO			###
:::000000$$$%%%.0###J<////b






	!	!	!#####rrc(eZdZeZfdZdZxZS)DictCursorMixinc,tg}jrCjjD]/}|j}||vr
|jdz|z}||0|_|r!j	rfdj	D_	dSdSdS)N.c:g|]}|Sr)r,)rErrs  rrz2DictCursorMixin._do_get_result.<locals>.<listcomp>s%@@@$..++@@@r)
superr<rrfieldsr
table_nameappend_fieldsr)rrfr	__class__s`   rr<zDictCursorMixin._do_get_results
   	"\(
$
$v6>><#-4D

d####!DL	Adj	A@@@@TZ@@@DJJJ	A	A	A	ArcZ|dS|t|j|Sr)	dict_typeziprr*s  rr,zDictCursorMixin._conv_rows*;4~~c$,44555r)rrrrOrr<r,
__classcell__)rs@rrr}sQIAAAAA6666666rrceZdZdZdS)
DictCursorz.A cursor which returns results as a dictionaryNrrrrrrrrrs8888rrcVeZdZdZdZdZeZdZdZdZ	dZ
dZd	ZddZ
dd
Zd
S)SSCursora
    Unbuffered Cursor, mainly useful for queries that return a lot of data,
    or for connections to remote servers over a slow network.

    Instead of copying every row of data into a buffer, this will fetch
    rows as needed. The upside of this is the client uses much less memory,
    and rows are returned much faster when traveling over a slow network
    or if the result set is very big.

    There are limitations, though. The MySQL protocol doesn't support
    returning the total number of rows, so the only way to tell how many rows
    there are is to iterate over every row returned. Also, it currently isn't
    possible to scroll backwards, as only the current row is held in memory.
    c|Srrr*s  rr,zSSCursor._conv_rowr-rc|j}|dS|j'|j|jur|j	|r	|d|_dS#d|_wxYwr)r	r_finish_unbuffered_queryrrs  rrzSSCursor.closes<F<#(D(DL11333	#,,..
,,..
#DOOOdDO""""s)A--	A6c|}|||d||jSNTr7rrs   rrWzSSCursor._querysQ||~~

1
&&&}rc.|dSrr@rs rrzSSCursor.nextsets}}}---rcZ||jS)zRead next row.)r,r_read_rowdata_packet_unbufferedrs r	read_nextzSSCursor.read_nexts"~~dlJJLLMMMrc||}||jj|_dS|xjdz
c_|S)zFetch next row.Nr)r(rrr
rr*s  rrzSSCursor.fetchonesOnn;!%!;D4!
rcDt|S)z
        Fetch all, as per MySQLdb. Pretty useless for large queries, as
        it is buffered. See fetchall_unbuffered(), if you want an unbuffered
        generator version of this method.
        )rNfetchall_unbufferedrs rrzSSCursor.fetchallsD,,..///rc,t|jdS)z
        Fetch all, implemented as a generator, which isn't to standard,
        however, it doesn't make sense to return everything in a list, as that
        would use ridiculous memory for large result sets.
        N)rtrrs rrzSSCursor.fetchall_unbufferedsDM4(((rNc|||j}g}t|D]P}|}||jj|_n&|||xjdz
c_Q|sdS|S)zFetch many.Nrr)r(rrrrr
rr)rrr|rr+s     rrzSSCursor.fetchmanys<>Dt	 	 A..""C{%)\%?"KKNNaNNN	2rrc||dkrR|dkrtjdt|D]}||xj|z
c_dS|dkrX||jkrtjd||jz
}t|D]}|||_dStjd|z)Nrrz0Backwards scrolling not supported by this cursorrr)r(rrrrrr%)rrr_rs     rrzSSCursor.scrolls:qyy+F5\\
!
!    NNe#NNNN
Z

t~%%+F$.(C3ZZ
!
!    "DNNN&'?$'FGGGrrr)rrrrr,r__del__rWrrrrrrrrrrrrs

###G...NNN000)))(HHHHHHrrceZdZdZdS)SSDictCursorz;An unbuffered cursor, which returns results as a dictionaryNrrrrrrsEEEErr)
rerr]rcompile
IGNORECASEDOTALLrarrrrrrrr<module>rsR				2:)MBI	i#i#i#i#i#i#i#i#X66666666099999&999vHvHvHvHvHvvHvHvHrFFFFF?HFFFFFr
Back to Directory File Manager