ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib64/python3.11/site-packages/pymysql/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/pymysql/__pycache__/cursors.cpython-311.pyc

�

�܋f�@����ddlZddlZddlmZejdejejz��ZGd�d��ZGd�d��Z	Gd	�d
e	e��Z
Gd�de��ZGd
�de	e��ZdS)�N�)�errz|\s*((?:INSERT|REPLACE)\b.+\bVALUES?\s*)(\(\s*(?:%s|%\(.+\)s)\s*(?:,\s*(?:%s|%\(.+\)s)\s*)*\))(\s*(?:ON DUPLICATE.*)?);?\s*\Zc���eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d"d
�Zd�Zd�Zd#d�Zd#d�Zd�Zd�Zd$d�Zd�Zd#d�Zd�Zd%d�Zd�Zd�Zd�Zd�Zd �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.
    i�c��||_d|_d|_d|_d|_d|_d|_d|_d|_dS)Nr���r)	�
connection�
warning_count�description�	rownumber�rowcount�	arraysize�	_executed�_result�_rows)�selfr	s  �F/opt/cloudlinux/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	�nextset�r�conns  r�closezCursor.close-s_������<��F�	#��,�,�.�.�
���,�,�.�.�
�#�D�O�O�O��d�D�O�"�"�"�"s	�)?�	Ac��|S�N��rs r�	__enter__zCursor.__enter__:����rc�0�~|���dSr)r)r�exc_infos  r�__exit__zCursor.__exit__=s����
�
�����rc�F�|jstjd���|jS)Nz
Cursor closed)r	r�ProgrammingErrorrs r�_get_dbzCursor._get_dbAs%����	8��&��7�7�7���rc�<�|jstjd���dS)Nzexecute() first)rrr%rs r�_check_executedzCursor._check_executedFs(���~�	:��&�'8�9�9�9�	:�	:rc��|Srr�r�rows  r�	_conv_rowzCursor._conv_rowJ����
rc��dS�z!Does nothing, required by DB API.Nr�r�argss  r�
setinputsizeszCursor.setinputsizesM����rc��dSr/rr0s  r�setoutputsizeszCursor.setoutputsizesPr3rFc���|���}|j}|�	||jurdS|jsdSd|_|���|�|���|���dS)zGet the next query set.N��
unbufferedT)r&r�has_next�
_clear_result�next_result�_do_get_result)rr8r�current_results    r�_nextsetzCursor._nextsetSs����|�|�~�~������!�^�4�<�%G�%G��4��&�	��4�������������J��/�/�/��������trc�,�|�d��S)NF�r>rs rrzCursor.nextsetas���}�}�U�#�#�#rc���t|ttf��rt�fd�|D����St|t��r �fd�|���D��S��|��S)Nc3�B�K�|]}��|��V��dSr��literal)�.0�argrs  �r�	<genexpr>z&Cursor._escape_args.<locals>.<genexpr>fs/�����;�;�s����c�*�*�;�;�;�;�;�;rc�B��i|]\}}|��|����SrrC)rE�key�valrs   �r�
<dictcomp>z'Cursor._escape_args.<locals>.<dictcomp>hs+���J�J�J�z��S�C����c�*�*�J�J�Jr)�
isinstance�tuple�list�dict�items�escape)rr1rs  `r�_escape_argszCursor._escape_argsds�����d�U�D�M�*�*�	%��;�;�;�;�d�;�;�;�;�;�;�
��d�
#�
#�	%�J�J�J�J�T�Z�Z�\�\�J�J�J�J��;�;�t�$�$�$rNc�d�|���}|�||�||��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)r�queryr1rs    r�mogrifyzCursor.mogrifyns6�� �|�|�~�~�����D�-�-�d�D�9�9�9�E��rc��|���r	|����|�||��}|�|��}||_|S)a�Execute 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)rrTr1�results    r�executezCursor.execute�s[���l�l�n�n�	���l�l�n�n�	����U�D�)�)�����U�#�#������
rc	�����|sdSt����}|r�|�d��dz}|�d�����}|�d��pd}|ddkr|d	d
ksJ���||||�j����j��St��fd�|D�����_	�j	S)a�Run 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().
        Nrr���r�(r�)c3�D�K�|]}���|��V��dSr)rY)rErFrTrs  ��rrGz%Cursor.executemany.<locals>.<genexpr>�s1�����E�E��D�L�L���4�4�E�E�E�E�E�Er)
�RE_INSERT_VALUES�match�group�rstrip�_do_execute_many�max_stmt_lengthr&�encoding�sumr
)rrTr1�m�q_prefix�q_values�	q_postfixs``     r�executemanyzCursor.executemany�s����� �	��F��"�"�5�)�)���	��w�w�q�z�z�B��H��w�w�q�z�z�(�(�*�*�H�����
�
�(�b�I��A�;�#�%�%�(�2�,�#�*=�*=�*=�=��(�(������$������'�
��
��E�E�E�E�E��E�E�E�E�E��
��}�rc�T�|���}|j}t|t��r|�|��}t|t��r|�|��}t|��}	t
|��}||t|��|��z}
t|
t��r|
�|d��}
|	|
z
}	d}|D]�}||||��z}
t|
t��r|
�|d��}
t|	��t|
��zt|��zdz|kr+||�	|	|z��z
}t|��}	n|	dz
}	|	|
z
}	��||�	|	|z��z
}||_
|S)N�surrogateescaperr�,)r&rRrL�str�encode�	bytearray�iter�next�lenrYr
)
r�prefix�values�postfixr1rfrgrrQ�sql�v�rowsrFs
             rrezCursor._do_execute_many�s����|�|�~�~���"���f�c�"�"�	-��]�]�8�,�,�F��g�s�#�#�	/��n�n�X�.�.�G�������D�z�z���V�V�D��J�J��-�-�-���a����	6�����#4�5�5�A��q������		�		�C�����T�*�*�*�A��!�S�!�!�
:��H�H�X�'8�9�9���3�x�x�#�a�&�&� �3�w�<�<�/�!�3�o�E�E�����S�7�]�3�3�3����'�'����t����1�H�C�C�����S�7�]�+�+�+����
��rrc������|����|r_d��d��|�dd���fd�t|��D����z��|���d��d��fd�t
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�,c3�R�K�|]!\}}�|��|��fzV��"dSr)rQ)rE�indexrFr�fmts   ��rrGz"Cursor.callproc.<locals>.<genexpr>sN�������8B��s�C�5�$�+�+�c�"2�"2�3�3������rzCALL {}({})c���g|]	}d�|fz��
S)z@_%s_%dr)rE�i�procnames  �r�
<listcomp>z#Cursor.callproc.<locals>.<listcomp>s"���J�J�J�A�i�8�Q�-�/�J�J�Jr)	r&rW�join�	enumerater�format�rangervr)rr�r1�qrr�s `  @@r�callproczCursor.callproc�s�����<�|�|�~�~���	�'�x�'�'�'�C��K�K���(�(������FO�PT�o�o�������
�
�
�
�L�L�N�N�N�� � ���H�H�J�J�J�J��s�4�y�y�9I�9I�J�J�J�K�K�
�
��	
���A��������rc��|���|j�|jt|j��krdS|j|j}|xjdz
c_|S)zFetch the next row.Nr�r(rrrv�rrXs  r�fetchonezCursor.fetchonesX���������:����3�t�z�?�?�!B�!B��4���D�N�+�����!�����
rc���|���|j�dS|j|p|jz}|j|j|�}t	|t|j����|_|S)zFetch several rows.Nr)r(rrr�minrv)r�size�endrXs    r�	fetchmanyzCursor.fetchmanysg���������:���2��n�� 6���7����D�N�S�0�1���S�#�d�j�/�/�2�2����
rc��|���|j�gS|jr|j|jd�}n|j}t|j��|_|S)zFetch all the rows.Nr�r�s  r�fetchallzCursor.fetchall&s\���������:���I��>�	 ��Z��� 0� 0�1�F�F��Z�F��T�Z������
r�relativec��|���|dkr|j|z}n |dkr|}ntjd|z���d|cxkrt	|j��ksnt
d���||_dS)Nr��absolute�unknown scroll mode %srzout of range)r(rrr%rvr�
IndexError)r�value�mode�rs    r�scrollz
Cursor.scroll2s����������:������&�A�A�
�Z�
�
��A�A��&�'?�$�'F�G�G�G��Q�(�(�(�(��T�Z���(�(�(�(��^�,�,�,�����rc��|���}|���|�|��|���|jSr�r&r:rTr<r
�rr�rs   rrWz
Cursor._query?sJ���|�|�~�~���������
�
�1�
�
�
��������}�rc�h�d|_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_idr�r|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__^s���m�m�o�o���;����
rc��|dvr1tjdtd���tt|��St|���)N)
�Warning�Error�InterfaceError�
DatabaseError�	DataError�OperationalError�IntegrityError�
InternalErrorr%�NotSupportedErrorz7PyMySQL errors hould be accessed from `pymysql` packager[)�
stacklevel)�warnings�warn�DeprecationWarning�getattrr�AttributeError)r�names  r�__getattr__zCursor.__getattr__dsZ���
�
�
�
�M�I�"��
�
�
�
�
�3��%�%�%��T�"�"�"r)Fr)r�r�) �__name__�
__module__�__qualname__�__doc__rfrrrr#r&r(r,r2r5r>rrRrUrYrmrer�r�r�r�r�rWr:r<r�r�r�rrrrrs����������O�	�	�	�#�#�#����������
:�:�:����0�0�0�0�0�0�����$�$�$�%�%�%�����.����0#�#�#�J���</�/�/�/�b���
�
�
�
�
�
�
�����������	!�	!�	!�������#�#�#�#�#rrc�(��eZdZeZ�fd�Zd�Z�xZS)�DictCursorMixinc�,���t�����g}�jrC�jjD]/}|j}||vr
|jdz|z}|�|���0|�_|r!�j	r�fd��j	D���_	dSdSdS)N�.c�:��g|]}��|����Sr)r,)rEr�rs  �rr�z2DictCursorMixin._do_get_result.<locals>.<listcomp>�s%���@�@�@��$�.�.��+�+�@�@�@r)
�superr<rr�fieldsr��
table_name�append�_fieldsr)rr��fr��	__class__s`   �rr<zDictCursorMixin._do_get_result�s�����
����� � � �����	"��\�(�
$�
$���v���6�>�>��<�#�-��4�D��
�
�d�#�#�#�#�!�D�L��	A�d�j�	A�@�@�@�@�T�Z�@�@�@�D�J�J�J�	A�	A�	A�	Arc�Z�|�dS|�t|j|����Sr)�	dict_type�zipr�r*s  rr,zDictCursorMixin._conv_row�s*���;��4��~�~�c�$�,��4�4�5�5�5r)r�r�r�rOr�r<r,�
__classcell__)r�s@rr�r�}sQ��������I�A�A�A�A�A�6�6�6�6�6�6�6rr�c��eZdZdZdS)�
DictCursorz.A cursor which returns results as a dictionaryN�r�r�r�r�rrrr�r��s������8�8�8�8rr�c�V�eZdZdZd�Zd�ZeZd�Zd�Zd�Z	d�Z
d�Zd	�Zdd�Z
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_row�r-rc���|j}|�dS|j�'|j|jur|j���	|���r	|����d|_dS#d|_wxYwr)r	r�_finish_unbuffered_queryrrs  rrzSSCursor.close�s�������<��F��<�#�����(D�(D��L�1�1�3�3�3�	#��,�,�.�.�
���,�,�.�.�
�#�D�O�O�O��d�D�O�"�"�"�"s�)A-�-	A6c��|���}|���|�|d���|���|jS�NTr7r�r�s   rrWzSSCursor._query�sQ���|�|�~�~���������
�
�1��
�&�&�&��������}�rc�.�|�d���Sr�r@rs rrzSSCursor.nextset�s���}�}��}�-�-�-rc�Z�|�|j�����S)zRead next row.)r,r�_read_rowdata_packet_unbufferedrs r�	read_nextzSSCursor.read_next�s"���~�~�d�l�J�J�L�L�M�M�Mrc��|���|���}|�|jj|_dS|xjdz
c_|S)zFetch next row.Nr)r(r�rr
rr*s  rr�zSSCursor.fetchone�sO���������n�n�����;�!%��!;�D���4����!�����
rc�D�t|�����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.
        )rN�fetchall_unbufferedrs rr�zSSCursor.fetchall�s���D�,�,�.�.�/�/�/rc�,�t|jd��S)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)rtr�rs rr�zSSCursor.fetchall_unbuffered�s���D�M�4�(�(�(rNc��|���|�|j}g}t|��D]P}|���}|�|jj|_n&|�|��|xjdz
c_�Q|sdS|S)zFetch many.Nrr)r(rr�r�rr
r�r)rr�r|r�r+s     rr�zSSCursor.fetchmany�s����������<��>�D����t���	 �	 �A��.�.�"�"�C��{�%)�\�%?��"����K�K������N�N�a��N�N�N��	��2��rr�c���|���|dkrR|dkrtjd���t|��D]}|����|xj|z
c_dS|dkrX||jkrtjd���||jz
}t|��D]}|����||_dStjd|z���)Nr�rz0Backwards scrolling not supported by this cursorr�r�)r(rr�r�r�rr%)rr�r��_r�s     rr�zSSCursor.scroll�s���������:����q�y�y��+�F�����5�\�\�
!�
!����� � � � ��N�N�e�#�N�N�N�N�
�Z�
�
��t�~�%�%��+�F�����$�.�(�C��3�Z�Z�
!�
!����� � � � �"�D�N�N�N��&�'?�$�'F�G�G�Grrr�)r�r�r�r�r,r�__del__rWrr�r�r�r�r�r�rrrr�r��s�������
�
����#�#�#��G����.�.�.�N�N�N����0�0�0�)�)�)�����(H�H�H�H�H�Hrr�c��eZdZdZdS)�SSDictCursorz;An unbuffered cursor, which returns results as a dictionaryNr�rrrr�r�s������E�E�E�Err�)
�rer�r]r�compile�
IGNORECASE�DOTALLrarr�r�r�r�rrr�<module>r�sR��	�	�	�	������������2�:�)��M�B�I��	���i#�i#�i#�i#�i#�i#�i#�i#�X6�6�6�6�6�6�6�6�09�9�9�9�9��&�9�9�9�vH�vH�vH�vH�vH�v�vH�vH�vH�rF�F�F�F�F�?�H�F�F�F�F�Fr

Zerion Mini Shell 1.0