AlkantarClanX12

Your IP : 3.139.108.48


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/MySQLdb/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/MySQLdb/__pycache__/cursors.cpython-37.pyc

B

���W�O�@sPdZddlmZmZddlmZddlZddlZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZmZmZejddkZer�e	ZneZe�dejejB�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�Z Gdd�de�Z!Gdd�de�Z"Gdd�de"�Z#Gdd�dee!e�Z$Gdd�dee"e�Z%Gdd�de e!e�Z&Gdd�de e"e�Z'dS)zyMySQLdb Cursors

This module implements Cursors of various types for MySQLdb. By
default, MySQLdb uses the Cursor class.
�)�print_function�absolute_import)�partialN)�unicode)
�Warning�Error�InterfaceError�	DataError�
DatabaseError�OperationalError�IntegrityError�
InternalError�NotSupportedError�ProgrammingError�zw\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
mZmZmZdZdZdd�Zd	d
�Zdd�Zd
d�Zd5dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Z d6d#d$�Z!d%d&�Z"d'd(�Z#d7d*d+�Z$d,d-�Z%d.d/�Z&d8d1d2�Z'd3d4�Z(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����)�
connection�description�description_flags�rowcount�	arraysize�	_executed�	lastrowid�messages�errorhandler�_result�	_warnings�	rownumber)�selfr�r"�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)r�nextsetrr)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|t�r|���}n*t|ttf�r@t|���fdd�|D��}|S)Nc3s|]}�j|�d�VqdS))�encodingN)�
_ensure_bytes)�.0�v)r*r!r"r#�	<genexpr>fsz+BaseCursor._ensure_bytes.<locals>.<genexpr>)�
isinstance�	text_type�encode�tuple�list�type)r!�xr*r")r*r!r#r+bs

zBaseCursor._ensure_bytescs�t|j�jd��t|ttf�rFtr0tt�|��}t�fdd�|D��St|t�r�trnt�fdd�|�	�D��}t�fdd�|�	�D��Str��|�}��
|�SdS)N)r*c3s|]}��|�VqdS)N)�literal)r,�arg)�connr"r#r.osz*BaseCursor._escape_args.<locals>.<genexpr>c3s"|]\}}�|��|�fVqdS)Nr")r,�key�val)�ensure_bytesr"r#r.rsc3s |]\}}|��|�fVqdS)N)r6)r,r9r:)r8r"r#r.ts)rr+r*r/r2r3�PY2�map�dict�itemsr6)r!�argsr8r")r8r;r#�_escape_argsis
zBaseCursor._escape_argscCs|js|�|td�dS)Nzexecute() first)rrr)r!r"r"r#�_check_executed|szBaseCursor._check_executedcCsddlm}|��}|jdkr(|��|_|jr�|j}d|_|jrv|jjrvd|f}|j�|�||�	d|�dd�dS|�
�}|r�x|D]}|j�|j	|f�q�WxZ|D]}||j	|dd��dd�q�Wn2|��}|r�|j�|j	|f�||�	d|�dd�dS)Nr)�warnzThere are %d MySQL warnings.�)�
stacklevelr)�warningsrC�_get_dbr�
warning_countrZhas_nextr�appendrZ
show_warnings�info)r!rC�dbrH�msgrF�wrJr"r"r#�_warning_check�s,




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

        Returns None if there are no more result sets.
        Nrr)r�fetchallrrGZnext_result�_do_get_result�_post_get_resultrN)r!rK�nrr"r"r#r%�szBaseCursor.nextsetcCsdS)Nr")r!r"r"r#rQ��zBaseCursor._post_get_resultcCsb|��}|��|_|��|_d|_|jr2|j��p4d|_|jrH|j��pJd|_	|�
�|_d|_dS)Nr)
rG�_get_resultrZ
affected_rowsrr ZdescriberZfield_flagsrZ	insert_idrr)r!rKr"r"r#rP�s


zBaseCursor._do_get_resultcGsdS)z!Does nothing, required by DB API.Nr")r!r@r"r"r#�
setinputsizes�szBaseCursor.setinputsizescGsdS)z!Does nothing, required by DB API.Nr")r!r@r"r"r#�setoutputsizes�szBaseCursor.setoutputsizescCs|j}|dkrtd��|S)Nz
cursor closed)rr)r!Zconr"r"r#rG�szBaseCursor._get_dbc
sRx|��rqW|���tr2t|t�r2|��jj�}|dk	r�t|t�r`t�fdd�|�	�D��}nt
t�j|��}ts�t|t
tf�r�|��jj�}y||}Wn4tk
r�}z|�|tt|��Wdd}~XYnXt|t�r�|��jjd�}d}y|�|�}Wn8tk
�r6t��dd�\}}|�|||�YnX||_|j�sN|��|S)a�Execute 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,r9�item)rKr"r#r.�sz%BaseCursor.execute.<locals>.<genexpr>�surrogateescaper)r%rGr<r/rr1�unicode_literal�charsetr>r?r2r=r6�bytes�	bytearray�decode�	TypeErrorrr�str�_query�	Exception�sysr(r�_defer_warningsrN)r!�queryr@�m�res�exc�valuer")rKr#�execute�s6
	
$
zBaseCursor.executec	s��jdd�=|sdSt���}|r�|�d�d}|�d���}|�d�pJd}|ddkrd|d	d
ksht���||||�j���j	�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"rrD�r�(r�)c3s|]}���|�VqdS)N)ri)r,r7)rdr!r"r#r.sz)BaseCursor.executemany.<locals>.<genexpr>)r�RE_INSERT_VALUES�match�group�rstrip�AssertionError�_do_execute_many�max_stmt_lengthrGr*�sumr)r!rdr@reZq_prefixZq_valuesZ	q_postfixr")rdr!r#�executemanys
zBaseCursor.executemanyc
CsN|��}|j}t|t�r"|�|�}tr:t|t�r:|�|�}t|t�rN|�|�}t|�}	t|�}||t|�|�}
t|
t�r�tr�|
�|�}
n|
�|d�}
|	|
7}	d}x�|D]�}||||�}
t|
t�r�tr�|
�|�}
n|
�|d�}
t	|	�t	|
�t	|�d|k�r||�
|	|�7}t|�}	n|	d7}	|	|
7}	q�W||�
|	|�7}||_|S)NrXrr�,)rGrAr/r0r1r<r\�iter�next�lenrir)
r!�prefix�valuesZpostfixr@rsr*r8�escapeZsqlr-Zrowsr7r"r"r#rrs>







"
zBaseCursor._do_execute_manyr"cs�|��}xTt|�D]H\}}d�||�|�f}t|t�rH|�|jjd�}|�|�|�	�qWd�d�
�fdd�tt|��D��f}t|t�r�|�|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=%srXzCALL %s(%s)�,csg|]}d�|f�qS)z@_%s_%dr")r,�i)�procnamer"r#�
<listcomp>isz'BaseCursor.callproc.<locals>.<listcomp>)rG�	enumerater6r/rr1rYrZr`r%�join�rangeryrrcrN)r!rr@rK�indexr7�qr")rr#�callprocBs$



zBaseCursor.callproccCs&|��}||_|�|�|��|jS)N)rGZ_last_executedrdrPr)r!r�rKr"r"r#�	_do_queryss

zBaseCursor._do_querycCs
|�|�S)N)r�)r!r�r"r"r#r`zszBaseCursor._queryrcCs|js
dS|j�||j�S)Nr")rZ	fetch_row�_fetch_type)r!�sizer"r"r#�
_fetch_row}szBaseCursor._fetch_rowcCst|jd�S)N)rw�fetchone)r!r"r"r#�__iter__�szBaseCursor.__iter__)N)N)r")r))�__name__�
__module__�__qualname__�__doc__rs�_mysql_exceptionsrrrrr
r	rrr
rrrcrr$r&r'r)r+rArBrNr%rQrPrUrVrGrirurrr�r�r`r�r�r"r"r"r#r#sJ4
"

4$
1
rc@sTeZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zd
d�Z	ddd�Z
dd�Zd
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#rT�sz"CursorStoreResultMixIn._get_resultcCs|�|�}|��|S)N)r�rQ)r!r�rr"r"r#r`�s
zCursorStoreResultMixIn._querycCs|�d�|_d|_dS)Nr)r��_rowsr)r!r"r"r#rQ�sz'CursorStoreResultMixIn._post_get_resultcCs8|��|jt|j�krdS|j|j}|jd|_|S)z]Fetches a single row from the cursor. None indicates that
        no more rows are available.Nr)rBr ryr�)r!�resultr"r"r#r��szCursorStoreResultMixIn.fetchoneNcCs>|��|j|p|j}|j|j|�}t|t|j��|_|S)z�Fetch up to size rows from the cursor. Result set may be smaller
        than size. If size is not defined, cursor.arraysize is used.)rBr rr��minry)r!r��endr�r"r"r#�	fetchmany�s
z CursorStoreResultMixIn.fetchmanycCs6|��|jr |j|jd�}n|j}t|j�|_|S)z*Fetchs all available rows from the cursor.N)rBr r�ry)r!r�r"r"r#rO�szCursorStoreResultMixIn.fetchall�relativecCsn|��|dkr|j|}n$|dkr*|}n|�|tdt|��|dksV|t|j�krd|�|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.r�Zabsolutezunknown scroll mode %srzout of rangeN)rBr rr�reprryr��
IndexError)r!rh�mode�rr"r"r#�scroll�szCursorStoreResultMixIn.scrollcCs,|��|jr|j|jd�p"|j}t|�S)N)rBr r�rw)r!r�r"r"r#r��szCursorStoreResultMixIn.__iter__)N)r�)r�r�r�r�rTr`rQr�r�rOr�r�r"r"r"r#r��s

	

r�c@sJeZdZdZdZdd�Zdd�Zddd	�Zd
d�Zdd
�Z	dd�Z
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#rT�rSz CursorUseResultMixIn._get_resultcCs6|��|�d�}|s"|��dS|jd|_|dS)z%Fetches a single row from the cursor.rNr)rBr�rNr )r!r�r"r"r#r��s
zCursorUseResultMixIn.fetchoneNcCs8|��|�|p|j�}|jt|�|_|s4|��|S)z�Fetch up to size rows from the cursor. Result set may be smaller
        than size. If size is not defined, cursor.arraysize is used.)rBr�rr ryrN)r!r�r�r"r"r#r��szCursorUseResultMixIn.fetchmanycCs.|��|�d�}|jt|�|_|��|S)z*Fetchs all available rows from the cursor.r)rBr�r ryrN)r!r�r"r"r#rO�s

zCursorUseResultMixIn.fetchallcCs|S)Nr")r!r"r"r#r�szCursorUseResultMixIn.__iter__cCs|��}|dkrt�|S)N)r��
StopIteration)r!�rowr"r"r#rxszCursorUseResultMixIn.next)N)r�r�r�r�rcrTr�r�rOr�rx�__next__r"r"r"r#r��s


r�c@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)r�r�r�r�r�r"r"r"r#r�
sr�c@s.eZdZdZdZdd�Zd
dd�Zdd	�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)rFrC�DeprecationWarningr�)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)rFrCr�r�)r!r�rCr"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)rFrCr�rO)r!rCr"r"r#�fetchallDict*sz CursorDictRowsMixIn.fetchallDict)N)r�r�r�r�r�r�r�r�r"r"r"r#r�s

r�c@seZdZdZdZdS)�CursorOldDictRowsMixInz�This is a MixIn class that returns rows as dictionaries with
    the same key convention as the old Mysqldb (MySQLmodule). Don't
    use this.rN)r�r�r�r�r�r"r"r"r#r�3sr�c@seZdZdZdS)�CursorzjThis is the standard Cursor class that returns rows as tuples
    and stores the result set in the client.N)r�r�r�r�r"r"r"r#r�;sr�c@seZdZdZdS)�
DictCursorzeThis is a Cursor class that returns rows as dictionaries and
    stores the result set in the client.N)r�r�r�r�r"r"r"r#r�Asr�c@seZdZdZdS)�SSCursorz_This is a Cursor class that returns rows as tuples and stores
    the result set in the server.N)r�r�r�r�r"r"r"r#r�Gsr�c@seZdZdZdS)�SSDictCursorzeThis is a Cursor class that returns rows as dictionaries and
    stores the result set in the server.N)r�r�r�r�r"r"r"r#r�Msr�)(r��
__future__rr�	functoolsr�rerbZMySQLdb.compatrr�rrrr	r
rrr
rr�version_infor<r0r_�compile�
IGNORECASE�DOTALLrm�objectrr�r�r�r�r�r�r�r�r�r"r"r"r#�<module>s:0pH4