• File: cursors.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/site-packages/MySQLdb/__pycache__/cursors.cpython-37.pyc
  • Date Modified: 03/07/2024 7:47 AM
  • File size: 18.97 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

WO@sPdZddlmZmZddlmZddlZddlZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZmZmZejddkZere	ZneZedejejBZGd	d
d
eZGdddeZGd
ddeZ GdddeZ!GdddeZ"Gddde"Z#Gdddee!eZ$Gdddee"eZ%Gddde e!eZ&Gddde e"eZ'dS)zyMySQLdb Cursors

This module implements Cursors of various types for MySQLdb. By
default, MySQLdb uses the Cursor class.
)print_functionabsolute_import)partialN)unicode)
WarningErrorInterfaceError	DataError
DatabaseErrorOperationalErrorIntegrityError
InternalErrorNotSupportedErrorProgrammingErrorzw\s*((?:INSERT|REPLACE)\s.+\sVALUES?\s+)(\(\s*(?:%s|%\(.+\)s)\s*(?:,\s*(?:%s|%\(.+\)s)\s*)*\))(\s*(?:ON DUPLICATE.*)?)\Zc@s0eZdZdZdZddlmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZdZdZddZd	d
ZddZd
dZd5ddZddZddZddZddZddZddZddZdd Zd!d"Z d6d#d$Z!d%d&Z"d'd(Z#d7d*d+Z$d,d-Z%d.d/Z&d8d1d2Z'd3d4Z(eZeZe	Z	e
Z
eZeZe
Z
eZeZeZdS)9
BaseCursoraA base for Cursor classes. Useful attributes:

    description
        A tuple of DB API 7-tuples describing the columns in
        the last executed query; see PEP-249 for details.

    description_flags
        Tuple of column flags for last query, one entry per column
        in the result set. Values correspond to those in
        MySQLdb.constants.FLAG. See MySQL documentation (C API)
        for more information. Non-standard extension.

    arraysize
        default number of rows fetchmany() will fetch
    ir)
MySQLErrorrrrr
r	rrr
rrFNcCsN||_d|_d|_d|_d|_d|_d|_g|_|j|_d|_	d|_
d|_dS)N)
connectiondescriptiondescription_flagsrowcount	arraysize	_executed	lastrowidmessageserrorhandler_result	_warnings	rownumber)selfrr"B/opt/alt/python37/lib64/python3.7/site-packages/MySQLdb/cursors.py__init__AszBaseCursor.__init__cCs:z |jdkrdSx|rqWWdd|_d|_d|_XdS)z6Close the cursor. No further queries will be possible.N)rnextsetrr)r!r"r"r#closeOs

zBaseCursor.closecCs|S)Nr")r!r"r"r#	__enter__[szBaseCursor.__enter__cGs~|dS)N)r&)r!exc_infor"r"r#__exit__^szBaseCursor.__exit__csDt|tr|}n*t|ttfr@t|fdd|D}|S)Nc3s|]}j|dVqdS))encodingN)
_ensure_bytes).0v)r*r!r"r#	<genexpr>fsz+BaseCursor._ensure_bytes.<locals>.<genexpr>)
isinstance	text_typeencodetuplelisttype)r!xr*r")r*r!r#r+bs

zBaseCursor._ensure_bytescst|jjdt|ttfrFtr0tt|}tfdd|DSt|trtrntfdd|	D}tfdd|	DStr|}
|SdS)N)r*c3s|]}|VqdS)N)literal)r,arg)connr"r#r.osz*BaseCursor._escape_args.<locals>.<genexpr>c3s"|]\}}||fVqdS)Nr")r,keyval)ensure_bytesr"r#r.rsc3s |]\}}||fVqdS)N)r6)r,r9r:)r8r"r#r.ts)rr+r*r/r2r3PY2mapdictitemsr6)r!argsr8r")r8r;r#_escape_argsis
zBaseCursor._escape_argscCs|js||tddS)Nzexecute() first)rrr)r!r"r"r#_check_executed|szBaseCursor._check_executedcCsddlm}|}|jdkr(||_|jr|j}d|_|jrv|jjrvd|f}|j|||	d|dddS|
}|rx|D]}|j|j	|fqWxZ|D]}||j	|ddddqWn2|}|r|j|j	|f||	d|dddS)Nr)warnzThere are %d MySQL warnings.)
stacklevelr)warningsrC_get_dbr
warning_countrZhas_nextrappendrZ
show_warningsinfo)r!rCdbrHmsgrFwrJr"r"r#_warning_checks,




 zBaseCursor._warning_checkcCsR|jr||jdd=|}|}|dkr6dS|||dS)z`Advance to the next result set.

        Returns None if there are no more result sets.
        Nrr)rfetchallrrGZnext_result_do_get_result_post_get_resultrN)r!rKZnrr"r"r#r%szBaseCursor.nextsetcCsdS)Nr")r!r"r"r#rQzBaseCursor._post_get_resultcCsb|}||_||_d|_|jr2|jp4d|_|jrH|jpJd|_	|
|_d|_dS)Nr)
rG_get_resultrZ
affected_rowsrr ZdescriberZfield_flagsrZ	insert_idrr)r!rKr"r"r#rPs


zBaseCursor._do_get_resultcGsdS)z!Does nothing, required by DB API.Nr")r!r@r"r"r#
setinputsizesszBaseCursor.setinputsizescGsdS)z!Does nothing, required by DB API.Nr")r!r@r"r"r#setoutputsizesszBaseCursor.setoutputsizescCs|j}|dkrtd|S)Nz
cursor closed)rr)r!Zconr"r"r#rGszBaseCursor._get_dbc
sRx|rqW|tr2t|tr2|jj}|dk	rt|tr`tfdd|	D}nt
tj|}tst|t
tfr|jj}y||}Wn4tk
r}z||tt|Wdd}~XYnXt|tr|jjd}d}y||}Wn8tk
r6tdd\}}||||YnX||_|jsN||S)aExecute a query.

        query -- string, query to execute on server
        args -- optional sequence or mapping, parameters to use with query.

        Note: If args is a sequence, then %s must be used as the
        parameter placeholder in the query. If a mapping is used,
        %(key)s must be used as the placeholder.

        Returns integer represents rows affected, if any
        Nc3s |]\}}||fVqdS)N)r6)r,r9item)rKr"r#r.sz%BaseCursor.execute.<locals>.<genexpr>surrogateescaper)r%rGr<r/rr1unicode_literalcharsetr>r?r2r=r6bytes	bytearraydecode	TypeErrorrrstr_query	Exceptionsysr(r_defer_warningsrN)r!queryr@mZresexcvaluer")rKr#executes6
	
$
zBaseCursor.executec	sjdd=|sdSt}|r|dd}|d}|dpJd}|ddkrd|d	d
ksht||||jj	St
fdd|D_jS)
axExecute a multi-row query.

        :param query: query to execute on server
        :param args:  Sequence of sequences or mappings.  It is used as parameter.
        :return: Number of rows affected, if any.

        This method improves performance on multiple-row INSERT and
        REPLACE. Otherwise it is equivalent to looping over args with
        execute().
        Nrr"rrDr(r)c3s|]}|VqdS)N)rg)r,r7)rcr!r"r#r.sz)BaseCursor.executemany.<locals>.<genexpr>)rRE_INSERT_VALUESmatchgrouprstripAssertionError_do_execute_manymax_stmt_lengthrGr*sumr)r!rcr@rdZq_prefixZq_valuesZ	q_postfixr")rcr!r#executemanys
zBaseCursor.executemanyc
CsN|}|j}t|tr"||}tr:t|tr:||}t|trN||}t|}	t|}||t||}
t|
trtr|
|}
n|
|d}
|	|
7}	d}x|D]}||||}
t|
trtr|
|}
n|
|d}
t	|	t	|
t	|d|kr||
|	|7}t|}	n|	d7}	|	|
7}	qW||
|	|7}||_|S)NrWrr,)rGrAr/r0r1r<r[iternextlenrgr)
r!prefixvaluesZpostfixr@rqr*r8escapeZsqlr-Zrowsr7r"r"r#rps>







"
zBaseCursor._do_execute_manyr"cs|}xTt|D]H\}}d|||f}t|trH||jjd}|||	qWdd
fddtt|Df}t|tr||jjd}||||_
|js||S)aExecute stored procedure procname with args

        procname -- string, name of procedure to execute on server

        args -- Sequence of parameters to use with procedure

        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.
        zSET @_%s_%d=%srWzCALL %s(%s),csg|]}d|fqS)z@_%s_%dr")r,i)procnamer"r#
<listcomp>isz'BaseCursor.callproc.<locals>.<listcomp>)rG	enumerater6r/rr1rXrYr_r%joinrangerwrrbrN)r!r}r@rKindexr7qr")r}r#callprocBs$



zBaseCursor.callproccCs&|}||_||||jS)N)rGZ_last_executedrcrPr)r!rrKr"r"r#	_do_queryss

zBaseCursor._do_querycCs
||S)N)r)r!rr"r"r#r_zszBaseCursor._queryrcCs|js
dS|j||jS)Nr")rZ	fetch_row_fetch_type)r!sizer"r"r#
_fetch_row}szBaseCursor._fetch_rowcCst|jdS)N)rufetchone)r!r"r"r#__iter__szBaseCursor.__iter__)N)N)r")r))__name__
__module____qualname____doc__rq_mysql_exceptionsrrrrr
r	rrr
rrrbrr$r&r'r)r+rArBrNr%rQrPrTrUrGrgrsrprrr_rrr"r"r"r#r#sJ4
"

4$
1
rc@sTeZdZdZddZddZddZdd	ZdddZd
dZ	dddZ
ddZd
S)CursorStoreResultMixInaThis is a MixIn class which causes the entire result set to be
    stored on the client side, i.e. it uses mysql_store_result(). If the
    result set can be very large, consider adding a LIMIT clause to your
    query, or using CursorUseResultMixIn instead.cCs|S)N)rGZstore_result)r!r"r"r#rSsz"CursorStoreResultMixIn._get_resultcCs||}||S)N)rrQ)r!rrr"r"r#r_s
zCursorStoreResultMixIn._querycCs|d|_d|_dS)Nr)r_rowsr)r!r"r"r#rQsz'CursorStoreResultMixIn._post_get_resultcCs8||jt|jkrdS|j|j}|jd|_|S)z]Fetches a single row from the cursor. None indicates that
        no more rows are available.Nr)rBr rwr)r!resultr"r"r#rszCursorStoreResultMixIn.fetchoneNcCs>||j|p|j}|j|j|}t|t|j|_|S)zFetch up to size rows from the cursor. Result set may be smaller
        than size. If size is not defined, cursor.arraysize is used.)rBr rrminrw)r!rendrr"r"r#	fetchmanys
z CursorStoreResultMixIn.fetchmanycCs6||jr |j|jd}n|j}t|j|_|S)z*Fetchs all available rows from the cursor.N)rBr rrw)r!rr"r"r#rOszCursorStoreResultMixIn.fetchallrelativecCsn||dkr|j|}n$|dkr*|}n||tdt||dksV|t|jkrd||td||_dS)aScroll the cursor in the result set to a new position according
        to mode.

        If mode is 'relative' (default), value is taken as offset to
        the current position in the result set, if set to 'absolute',
        value states an absolute target position.rZabsolutezunknown scroll mode %srzout of rangeN)rBr rrreprrwr
IndexError)r!rfmoderr"r"r#scrollszCursorStoreResultMixIn.scrollcCs,||jr|j|jdp"|j}t|S)N)rBr rru)r!rr"r"r#rszCursorStoreResultMixIn.__iter__)N)r)rrrrrSr_rQrrrOrrr"r"r"r#rs

	

rc@sJeZdZdZdZddZddZddd	Zd
dZdd
Z	ddZ
e
ZdS)CursorUseResultMixInaThis is a MixIn class which causes the result set to be stored
    in the server and sent row-by-row to client side, i.e. it uses
    mysql_use_result(). You MUST retrieve the entire result set and
    close() the cursor before additional queries can be performed on
    the connection.TcCs|S)N)rGZ
use_result)r!r"r"r#rSrRz CursorUseResultMixIn._get_resultcCs6||d}|s"|dS|jd|_|dS)z%Fetches a single row from the cursor.rNr)rBrrNr )r!rr"r"r#rs
zCursorUseResultMixIn.fetchoneNcCs8|||p|j}|jt||_|s4||S)zFetch up to size rows from the cursor. Result set may be smaller
        than size. If size is not defined, cursor.arraysize is used.)rBrrr rwrN)r!rrr"r"r#rszCursorUseResultMixIn.fetchmanycCs.||d}|jt||_||S)z*Fetchs all available rows from the cursor.r)rBrr rwrN)r!rr"r"r#rOs

zCursorUseResultMixIn.fetchallcCs|S)Nr")r!r"r"r#rszCursorUseResultMixIn.__iter__cCs|}|dkrt|S)N)r
StopIteration)r!rowr"r"r#rvszCursorUseResultMixIn.next)N)rrrrrbrSrrrOrrv__next__r"r"r"r#rs


rc@seZdZdZdZdS)CursorTupleRowsMixInzwThis is a MixIn class that causes all rows to be returned as tuples,
    which is the standard form required by DB API.rN)rrrrrr"r"r"r#r
src@s.eZdZdZdZddZd
ddZdd	ZdS)CursorDictRowsMixInznThis is a MixIn class that causes all rows to be returned as
    dictionaries. This is a non-standard feature.rcCs ddlm}|dtd|S)zgFetch a single row as a dictionary. Deprecated:
        Use fetchone() instead. Will be removed in 1.3.r)rCz9fetchoneDict() is non-standard and will be removed in 1.3r)rFrCDeprecationWarningr)r!rCr"r"r#fetchoneDictsz CursorDictRowsMixIn.fetchoneDictNcCs"ddlm}|dtd||S)zrFetch several rows as a list of dictionaries. Deprecated:
        Use fetchmany() instead. Will be removed in 1.3.r)rCz:fetchmanyDict() is non-standard and will be removed in 1.3r)rFrCrr)r!rrCr"r"r#
fetchmanyDict"sz!CursorDictRowsMixIn.fetchmanyDictcCs ddlm}|dtd|S)zwFetch all available rows as a list of dictionaries. Deprecated:
        Use fetchall() instead. Will be removed in 1.3.r)rCz9fetchallDict() is non-standard and will be removed in 1.3r)rFrCrrO)r!rCr"r"r#fetchallDict*sz CursorDictRowsMixIn.fetchallDict)N)rrrrrrrrr"r"r"r#rs

rc@seZdZdZdZdS)CursorOldDictRowsMixInzThis is a MixIn class that returns rows as dictionaries with
    the same key convention as the old Mysqldb (MySQLmodule). Don't
    use this.rN)rrrrrr"r"r"r#r3src@seZdZdZdS)CursorzjThis is the standard Cursor class that returns rows as tuples
    and stores the result set in the client.N)rrrrr"r"r"r#r;src@seZdZdZdS)
DictCursorzeThis is a Cursor class that returns rows as dictionaries and
    stores the result set in the client.N)rrrrr"r"r"r#rAsrc@seZdZdZdS)SSCursorz_This is a Cursor class that returns rows as tuples and stores
    the result set in the server.N)rrrrr"r"r"r#rGsrc@seZdZdZdS)SSDictCursorzeThis is a Cursor class that returns rows as dictionaries and
    stores the result set in the server.N)rrrrr"r"r"r#rMsr)(rZ
__future__rr	functoolsrreraZMySQLdb.compatrrrrrr	r
rrr
rrversion_infor<r0r^compile
IGNORECASEDOTALLrkobjectrrrrrrrrrrr"r"r"r#<module>s:0pH4