Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/engine/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/engine/__pycache__/cursor.cpython-312.pyc
�

���g*�	��UdZddlmZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl!m#Z#ddl!m Z$ddl%m&Z&dd l'm(Z(dd!l'm)Z)dd"l'm*Z*dd#l'm+Z+dd$l'm,Z,dd%l-m.Z.dd&l m/Z/dd'l0m1Z1dd(l0m2Z2ej$rNdd)l3m4Z4dd*l5m6Z6dd+l7m8Z8dd,l7m9Z9dd-l7m:Z:dd.l7m;Z;dd/lm<Z<dd0lm=Z=dd1lm>Z>dd2lm?Z?dd3lm@Z@dd4lmAZAdd5l-mBZBed6e�7�ZCdZDd8eEd9<	dZFd:eEd;<	dZGd<eEd=<	d>ZHd?eEd@<	dAZIdBeEdC<	dDZJdEeEdF<	dGZKdHeEdI<	eeeLeLeeeMeMedJeeMfZNe
dKeNfZOeeLeLeeeMeMedJeMfZPGdL�dMe�ZQGdN�dO�ZRGdP�dQeR�ZSGdR�dSeS�ZTeT�ZUGdT�dUeS�ZVeV�ZWGdV�dWeR�ZXeX�ZYGdX�dYeX�ZZGdZ�d[eX�Z[Gd\�d]e�Z\e\�Z]dad^�Z^Gd_�d`eeC�Z_e_Z`y)bzNDefine cursor-specific result set constructs including
:class:`.CursorResult`.�)�annotationsN)�Any)�cast)�ClassVar)�Dict)�Iterator)�List)�Mapping)�NoReturn)�Optional)�Sequence)�Tuple)�
TYPE_CHECKING)�TypeVar)�Union�)�IteratorResult)�MergedResult)�Result)�ResultMetaData)�SimpleResultMetaData)�tuplegetter)�Row�)�exc)�util)�elements)�sqltypes)�_generative)�ResultColumnsEntry)�RM_NAME)�
RM_OBJECTS)�RM_RENDERED_NAME)�RM_TYPE)�
TypeEngine)�compat)�Literal)�Self)�
Connection)�DefaultExecutionContext)�_DBAPICursorDescription)�DBAPICursor)�Dialect)�ExecutionContext)�
_KeyIndexType)�_KeyMapRecType)�_KeyMapType)�_KeyType)�_ProcessorsType)�_TupleGetterType)�_ResultProcessorType�_T)�boundz
Literal[0]�MD_INDEXz
Literal[1]�MD_RESULT_MAP_INDEXz
Literal[2]�
MD_OBJECTS�z
Literal[3]�
MD_LOOKUP_KEY�z
Literal[4]�MD_RENDERED_NAME�z
Literal[5]�MD_PROCESSOR�z
Literal[6]�MD_UNTRANSLATEDz_ResultProcessorType[Any]r2c�b�eZdZUdZdZded<ded<ded<d	ed
<d	ed<ded
<dZded<d'd�Zd(d�Z																		d)d�Z	d*d�Z
				d+d�Zd,d�Zd-d�Z
				d.d�Zd�Zd�Zd�Zd�Ze	d/					d0d��Zd�Zes
	d1							d2d�Zd �Zd1d3d!�Zd"�Z				d4d#�Zd$�Zd%�Zy&)5�CursorResultMetaDataz"Result metadata for DBAPI cursors.)	�_keymap�_processors�_keys�_keymap_by_result_column_idx�_tuplefilter�_translated_indexes�_safe_for_cache�
_unpickled�
_key_to_index�_CursorKeyMapTyperEr3rFz#Optional[Dict[int, _KeyMapRecType]]rH�boolrLrK�Optional[List[int]]rJTzClassVar[bool]�returns_rowsc��||jvS�N)rE��self�keys  �I/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/engine/cursor.py�_has_keyzCursorResultMetaData._has_key�s���d�l�l�"�"�c��t|j|jD�cgc]}|j|t��c}��Scc}w)N)�extra)rrGrEr:rTs  rW�_for_freezez CursorResultMetaData._for_freeze�s=��#��J�J�<@�J�J�G�J�S�4�<�<��$�Z�0�J�G�
�	
��Gs�A
c��|jj|j�}	||	_||	_||	_||	_||	_||	_||	_||	_	|j|t�|	_|	SrS)
�	__class__�__new__rLrFrGrErIrJrKrH�_make_key_to_indexr8rM)
rU�	unpickled�
processors�keys�keymap�tuplefilter�translated_indexes�safe_for_cache�keymap_by_result_column_idx�new_objs
          rW�_make_new_metadataz'CursorResultMetaData._make_new_metadata�st���.�.�(�(����8��&���(�����
� ���*���&8��#�"0���/J��,� $� 7� 7��� I����rYc�J�|jrJ�|j|jdgt|j�zdd|j
j
�D��cic]\}}||dddz|ddz��c}}|j|j|j��Scc}}w)Nrr?rSrA)rarbrerfrdrcrgrh)
rIrjrL�lenrFrE�itemsrGrKrH)rUrV�values   rW�_remove_processorsz'CursorResultMetaData._remove_processors�s����$�$�$�$��&�&��o�o��v��D�$4�$4� 5�5��#�#'�,�,�"4�"4�"6��"6�J�C���U�1�Q�Z�'�)�E�!�"�I�5�5�"6������/�/�(,�(I�(I�'�
�	
��
s�Bc�>�|jrJ�t|j�}t|j�}|j|jj
�D��cic]'\}}||d�||vr|d|znd|d|zg|dd����)c}}�|j|j|j|jzdd|j|jz||j|j�D�cic]}|t|��c}��Scc}}wcc}w)Nrrr)rarbrerfrcrdrgrh)
rI�dictrErlrG�updatermrjrLrFrK�valuesr9)rU�otherrd�offsetrVrn�metadata_entrys       rW�_splice_horizontallyz)CursorResultMetaData._splice_horizontally�sE���$�$�$�$��d�l�l�#���T�Z�Z����
�
�#(�-�-�"5�"5�"7�
�#8�J�C���!��8�/�C�v�4E��a��6�)�!��!�H�v�%�	��1�2�Y�	�	�#8�
�	
��&�&��o�o��'�'�%�*;�*;�;��#����e�k�k�)���/�/�'-�m�m�o�)�&5�N��2�3�^�C�&5�)�'�
�	
��
��,)s�!,D
�;Dc
�J�t|j|��}|D�cgc]}|t��
}}|D�cgc]}|t��
}}|jr|D�cgc]}|j|��}}t|�}t
|�D��cgc]\}}|f|ddz��}	}}|	D�cic]}|t|��}
}|
jd�|	D��|j|j|j||||
|j|j��Scc}wcc}wcc}wcc}}wcc}w)Nrc3�HK�|]}|txsdD]}||f���
�y�w)�N)r:)�.0�new_rec�es   rW�	<genexpr>z/CursorResultMetaData._reduce.<locals>.<genexpr>s6����
�#���Z�(�.�B�.����L�.�
�#��� ")rarbrcrerfrdrgrh)
�list�_metadata_for_keysr8r<rJr�	enumeraterrrjrLrFrKrH)rUrc�recs�rec�indexes�new_keys�idx�tup�index�new_recsrds           rW�_reducezCursorResultMetaData._reduce�s8���D�+�+�D�1�2��,0�1�D�S�3�x�=�D��1�=A�B�T�c�s�=�1�T��B��#�#�@G�H���t�/�/��4��G�H��7�#��9B�4��I��:�5�#�U�H�s�1�2�w�&���I�5=�>�X�c�#�m�$�c�)�X��>�	�
�
�
�#�
�	
��&�&��o�o��'�'���&���/�/�(,�(I�(I�'�	
�		
��%2��B��I��I��>s�D�D�D�D�D c���|jr|jjs|S|jj}|j}trt|tj�sJ�||ur|S|�J�|j}|�7|jj�D�cic]}|t|��c}x}|_|jrJ�|jtj|jt!|j"�D��cic]\}}||vr|||��c}}�|j$|j&dd|j(|j*|j��Scc}wcc}}w)a[When using a cached Compiled construct that has a _result_map,
        for a new statement that used the cached Compiled, we need to ensure
        the keymap has the Column objects from our new statement as keys.
        So here we rewrite keymap with new entries for the new columns
        as matched to those of the cached statement.

        N)rdrarbrerfrcrgrh)�compiled�_result_columns�	statement�invoked_statementr�
isinstancer�
ClauseElementrHrErsr9rIrjr&�
dict_unionr��_all_selected_columnsrLrFrGrK)rU�context�compiled_statementr��keymap_by_positionrvr��news        rW�_adapt_to_contextz&CursorResultMetaData._adapt_to_contexts������w�'7�'7�'G�'G��K�$�-�-�7�7��#�5�5����/��1G�1G�H�H�H��!2�2��K� �,�,�,�"�>�>���%�
'+�l�l�&9�&9�&;�F�&;�N��2�3�^�C�&;�F�
���!B�
�$�$�$�$��&�&��$�$����%.�)�?�?�%��%���S��0�0�	�+�C�0�0�%��	��o�o��'�'��#�����/�/�(,�(I�(I�#'�
�	
��
F��s�E�E"c
��|j}d|_d|_dx|_|_|j
r|j
\}}}}}t
|�}	ndx}x}x}	x}x}}|j||||	||||�}
|
D�cgc]}|t��
c}|_	d|_
|	�r+|
D�cic]}|t|��}}t
|�|	k7r�i}
t�}|
D]O}|tf|txsdzD]2}|t}|
j!||�|k7s�"|j#|��4�Q|
D��cic] }|tr|tD]	}||vr||���"c}}|_|j'|D�cic]}|ddg||ddf��c}�n/|
D��cic]}|tr|tD]}||���c}}|_|j$j'|�n|
D�cic]}|t|��c}|_|	sZ|j(rN|j$j'|
D�cic])}|t*r|t*|j$|t��+c}�|j-|j$t�|_ycc}wcc}wcc}}wcc}wcc}}wcc}wcc}w)NFrz)r�rIrJrKrL�result_column_structrl�_merge_cursor_descriptionr@rFrHr<�setr>r:r8�
setdefault�addrErr�_translate_colnamerBr`rM)rU�parent�cursor_descriptionr��result_columns�cols_are_ordered�textual_ordered�ad_hoc_textual�loose_column_name_matching�num_ctx_cols�rawrv�by_key�index_by_key�dupesrVr��obj_elems                  rW�__init__zCursorResultMetaData.__init__[s?��
�.�.�� ���#'�� �16�6���t���'�'��,�,�

�� ���*��~�.�L��	
�N�
�-�
��
��
�!;��
�,�,��������&�	
��@C�
�?B�^�N�<�(�s�
���-1��)�
�'*��&)�N��}�-�~�=�&)�
��
�6�{�l�*�02�����&)�N� .�/?� @�B�&�z�2�8�b� ��-�X�6��(�2�2�3��<��C�!�I�I�c�N� �'*�+.� �*-��%�j�1�$2�:�$>���u�,�	�n�,�%?��*-� ����
�
�$)��#(�C��d�D�"�c�3��d�C�C�#(���+.� �*-��%�j�1�$2�:�$>���n�,�%?��*-� ���
�L�L����'�
'*��&)�N��}�-�~�=�&)��D�L��� :� :��L�L���
+.�	�+.��%�o�6�	#�?�3�T�\�\�&�}�5�6��+.�	�
�"�4�4�T�\�\�8�L����U
����D ���� ����s*�;I'�!I,�'%I1�$I7�!I<�J�.Jc	��|r�|r�|s�|t|�k(r~|D�	cgc]}	|	d��	c}	|_d|_t|�D�
�cgc]H\}
}|
|
|t|t
|t|j|t|t||
d�df��Jc}}
S|s|r)t|�|k(rd|_|j|||�}n7|rd|_|j||||�}nd|_|j||�}|D�
�
�����cgc]$\}
}
}}}}}|
|
||||j|||�|f��&c}}}}}}
}
Scc}	wcc}}
wcc}}}}}}
}
w)a#Merge a cursor.description with compiled result column information.

        There are at least four separate strategies used here, selected
        depending on the type of SQL construct used to start with.

        The most common case is that of the compiled SQL expression construct,
        which generated the column names present in the raw SQL string and
        which has the identical number of columns as were reported by
        cursor.description.  In this case, we assume a 1-1 positional mapping
        between the entries in cursor.description and the compiled object.
        This is also the most performant case as we disregard extracting /
        decoding the column names present in cursor.description since we
        already have the desired name we generated in the compiled SQL
        construct.

        The next common case is that of the completely raw string SQL,
        such as passed to connection.execute().  In this case we have no
        compiled construct to work with, so we extract and decode the
        names from cursor.description and index those as the primary
        result row target keys.

        The remaining fairly common case is that of the textual SQL
        that includes at least partial column information; this is when
        we use a :class:`_expression.TextualSelect` construct.
        This construct may have
        unordered or ordered column information.  In the ordered case, we
        merge the cursor.description and the compiled construct's information
        positionally, and warn if there are additional description names
        present, however we still decode the names in cursor.description
        as we don't have a guarantee that the names in the columns match
        on these.   In the unordered case, we match names in cursor.description
        to that of the compiled construct based on name matching.
        In both of these cases, the cursor.description names and the column
        expression objects and names are indexed as result row target keys.

        The final case is much less common, where we have a compiled
        non-textual SQL expression construct, but the number of columns
        in cursor.description doesn't match what's in the compiled
        construct.  We make the guess here that there might be textual
        column expressions in the compiled construct that themselves include
        a comma in them causing them to split.  We do the same name-matching
        as with textual non-ordered columns.

        The name-matched system of merging is the same as that used by
        SQLAlchemy for all cases up through the 0.9 series.   Positional
        matching for compiled SQL expressions was introduced in 1.0 as a
        major performance feature, and positional matching for textual
        :class:`_expression.TextualSelect` objects in 1.1.
        As name matching is no longer
        a common case, it was acceptable to factor it into smaller generator-
        oriented methods that are easier to understand, but incur slightly
        more performance overhead.

        rTrNF)rlrGrKr�r"r!r#�get_result_processorr$�_merge_textual_cols_by_position�_merge_cols_by_name�_merge_cols_by_none)rUr�r�r�r�r�r�r�r��elemr��
rmap_entry�raw_iterator�ridx�cursor_colname�mapped_type�coltype�obj�untranslateds                   rWr�z.CursorResultMetaData._merge_cursor_description�s���F
� �#���$6� 7�7�.<�=�n�d�$�q�'�n�=�D�J�$(�D� �(1��'@��(A�O�C�����z�*��w�'��/�0��0�0�"�7�+�"�#3�4�*�3�/��2��
��(A��
�(��3�'9�#:�l�#J�'+��$�#�C�C��/�� ���
(-��$�#�7�7��&�"�.�	 ��(-��$�#�7�7��/� ��0"�)��("����"���� �#���"�"��0�0�#�^�W��!�
�&"�)�
��s>����`�s�D3�A
D8�)D>c#�0K�|j}|j}|jr|jnd}d}g|_t|�D]I\}}|d}	|d}
|r||	�\}	}|r||	�}	|jj
|	�||	||
f���Ky�w)z�Extract column names and data types from a cursor.description.

        Applies unicode decoding, column translation, "normalization",
        and case sensitivity rules to the names based on the dialect.

        Nrr)�dialectr��requires_name_normalize�normalize_namerGr��append)rUr�r�r��translate_colnamer�r�r�r��colnamer�s           rW�_colnames_from_descriptionz/CursorResultMetaData._colnames_from_description�s������/�/��#�6�6��&-�&E�&E�G�"�"�4�	�����
�!�"4�5�H�C���!�f�G��!�f�G� �(9�'�(B�%����(��1���J�J���g�&��w��g�5�5�6�s�BBc#�K�t|�}|t|�kDr#tjd|t|�fz�t�}|j	||�D]{\}}}}	||krP||}
|
t
}|}|
t}
|d|vrtjd|dz��|j|d�ntj}
d}d}||||
|	||f���}y�w)NzVNumber of columns in textual SQL (%d) is smaller than number of columns requested (%d)rz8Duplicate column expression requested in textual SQL: %r)rlr�warnr�r�r"r$r�InvalidRequestErrorr�r�NULLTYPE)rUr�r�r�r��seenr�r�r�r��ctx_recr�r�r�s              rWr�z4CursorResultMetaData._merge_textual_cols_by_position�s�����>�*���#�0�1�1��I�I�@���%7�!8�9�:�
�
�u���
,�
,�W�6H�
I�
������\�!�(��-���j�)����%�g�.���q�6�T�>��1�1�-�/2�1�v�6�������Q�� �&�/�/�������t�W�k�7�C��M�M�!J�s�CCc#��K�|j||�}|j||�D]'\}}}}		||}
|
d}|
d}|
d}
||
|||	||f���)y#t$rtj}d}d}
Y�-wxYw�w)Nrrr;)�_create_description_match_mapr��KeyErrorrr�)rUr�r�r�r��	match_mapr�r�r�r�r�r�r��result_columns_idxs              rWr�z(CursorResultMetaData._merge_cols_by_name�s������6�6��6�
�	��
,�
,�W�6H�
I�
�����	
0�#�G�,���a�j��%�a�j��%,�Q�Z�"��"�������
�J���
*�&�/�/����%)�"�
*�s'�-A5�A�A5�A2�/A5�1A2�2A5c	�:�i}t|�D]�\}}|t}||vr||\}}}	}
|||tz|	|f||<n|t|t|t|f||<|s�R|tD]-}|j||t|t|t|f��/��|S)z�when matching cursor.description to a set of names that are present
        in a Compiled object, as is the case with TextualSelect, get all the
        names we expect might match those in cursor.description.
        )r�r#r"r!r$r�)�clsr�r��dr�r�rV�e_name�e_obj�e_type�e_ridx�r_keys            rWr�z2CursorResultMetaData._create_description_match_map�s��� 
�	
�$�N�3�J�D�$��'�(�C��a�x�
12�#��-���v�v����j�)9�!9�6�4�G��#���w�-��j�)9�4��=�$�O��#��)�"�*�-�E��L�L���g���Z�(8�$�w�-��N��.�%4�.�rYc#�vK�|j||�D] \}}}}|d|tj|d|f���"y�wrS)r�rr�)rUr�r�r�r�r�r�s       rWr�z(CursorResultMetaData._merge_cols_by_nonesW�����
,�
,�W�6H�
I�
���������!�!�����
�J�s�79c���|rh|jr0t|tj�rt	j
d�|�t	j
dt
j|�z�|�y)Nz9Row was unpickled; lookup by ColumnElement is unsupportedz.Could not locate column in row for column '%s')rLr�r�
ColumnElementr�NoSuchColumnErrorr�string_or_unprintable)rUrV�err�raiseerrs    rW�
_key_fallbackz"CursorResultMetaData._key_fallback.so����?�?�z�#�x�7M�7M�'N��/�/�)����
�/�/�H��4�4�S�9�:����
rYc�@�tjd|tz��)Nz<Ambiguous column name '%s' in result set column descriptions)rr�r<)rUr�s  rW� _raise_for_ambiguous_column_namez5CursorResultMetaData._raise_for_ambiguous_column_name?s(���%�%�
-�/2�=�/A�
B�
�	
rYc���t|t�r|j|}	|j|}|d}|�|j
|�|S#t$r!}|j|||�}|�J�Yd}~yd}~wwxYw�Nr)r��intrGrEr�r�r�)rUrVr�r��ke�xr�s       rW�_index_for_keyz#CursorResultMetaData._index_for_keyEs����c�3���*�*�S�/�C�	��,�,�s�#�C��A����=��1�1�#�6�����	��"�"�3��H�5�A��9��9���	�s�A
�
	A4�A/�/A4c���	|D�cgc]}|j|d��c}Scc}w#t$r.}tj||jd|�Yd}~yd}~wwxYwr�)rEr�rDr��args)rUrcrVr�s    rW�_indexes_for_keysz&CursorResultMetaData._indexes_for_keysXs]��	E�48�9�D�S�D�L�L��%�a�(�D�9�9��9���	E� �.�.�t�R�W�W�Q�Z��D�D��	E�s �'�"�'�'�	A�$A�Ac#�`K�|D]k}t|jjvr|j|}	|j|}t}|�|j|�tt|����my#t
$r.}tj||jd|�Yd}~�cd}~wwxYw�wr�)
r�r^�__mro__rGrEr�rDr�r�r8r�r�_NonAmbigCursorKeyMapRecType)rUrcrVr�r�r�s      rWr�z'CursorResultMetaData._metadata_for_keys_s������C��c�m�m�+�+�+��j�j��o��
I��l�l�3�'��
��M�E��}��5�5�c�:��3�S�9�9����
I�$�2�2�4������R�H�H��
I�s.�1B.�A4�1B.�4	B+�=$B&�!B.�&B+�+B.c��|jj�D��cic]:\}}t|ttf�r||t
|tg||tddf��<c}}|j|jd�Scc}}w)N)rErGrJ)
rErmr��strr�r8r9r>rGrJ)rUrVr�s   rW�__getstate__z!CursorResultMetaData.__getstate__ss���!%��� 2� 2� 4��!5�H�C���c�C��:�.����M��+�,����(�)�����!5���Z�Z�#'�#;�#;�
�	
��s�?A9c�n�tt|d��D�cgc]}d��c}|_|d|_d|_|j|jt�|_|d|_d|_	|dr,td|d�|_t|j�|_
ydx|_|_
ycc}w)NrGrETrJz	List[int])�rangerlrFrErHr`r8rMrGrLrrJrrI)rU�state�_s   rW�__setstate__z!CursorResultMetaData.__setstate__�s���*/��E�'�N�0C�*D�E�*D�Q�D�*D�E����Y�'���,0��)�!�4�4�T�\�\�8�L����7�^��
�����&�'�'+��U�#8�9�(�D�$�!,�T�-E�-E� F�D��;?�?�D�$�t�'8��Fs�	B2N)rVr�returnrO)r�r)rarOrbr3rcz
Sequence[str]rdr1rezOptional[_TupleGetterType]rfrPrgrOrhrr�rD)r�rD)rtrDr�rD)rczSequence[_KeyIndexType]r�r)r�r.r�r)r��CursorResult[Any]r�r+�F)r�zList[ResultColumnsEntry]r�rOr�zKDict[Union[str, object], Tuple[str, Tuple[Any, ...], TypeEngine[Any], int]])T)rVrr�zOptional[Exception]r�rOr�zOptional[NoReturn])rVrr�rOr��
Optional[int])rcz
Sequence[Any]r�z&Iterator[_NonAmbigCursorKeyMapRecType])�__name__�
__module__�__qualname__�__doc__�	__slots__�__annotations__rQrXr\rjrorwr�r�r�r�r�r�r��classmethodr�r�rr�r�r�r�r�r�r�rzrYrWrDrD�s���,��I��� � �"E�E�����,�,�#'�L�.�'�#�
����$�	�
���
�0��0����&)��
��0
� "
�)�"
�	�"
�H
�@<
�|SM�!�SM�4�SM�jV�p6�>"N�H$�L�,1�'�0�'�%)�'�
�	'��'�R�"�HL�	��	�!4�	�@D�	�
�	�"
��&E�:�!�:�	/�:�(
�(
@rYrDc���eZdZUdZdZdZded<						d
d�Z						d
d�Z								dd�Z		d							dd	�Z
	d							dd
�Z						dd�Z								dd�Z
y)�ResultFetchStrategyzQDefine a fetching strategy for a result object.


    .. versionadded:: 1.4

    rzN�!Optional[_DBAPICursorDescription]�alternate_cursor_descriptionc��t��rS��NotImplementedError�rU�result�dbapi_cursors   rW�
soft_closezResultFetchStrategy.soft_close��
��"�#�#rYc��t��rSrrs   rW�
hard_closezResultFetchStrategy.hard_close�rrYc��yrSrz�rUr	r
�nums    rW�	yield_perzResultFetchStrategy.yield_per�s��	rYc��t��rSr�rUr	r
rs    rW�fetchonezResultFetchStrategy.fetchone��
��"�#�#rYc��t��rSr�rUr	r
�sizes    rW�	fetchmanyzResultFetchStrategy.fetchmany�rrYc��t��rSrrs   rW�fetchallzResultFetchStrategy.fetchall�s
��
"�#�#rYc��|�rSrz�rUr	r
r�s    rW�handle_exceptionz$ResultFetchStrategy.handle_exception�s	���	rY�r	r�r
�Optional[DBAPICursor]r��None�r	r�r
r!rr�r�r"r��r	r�r
r,rrOr�rrS�r	r�r
r,rr�r�r�r	r�r
r,r�r�r	r�r
r!r��
BaseExceptionr�r)r�r�r�r�r�rr�rrrrrrrrzrYrWrr�s+����I�FJ� �"C�J�$�'�$�7L�$�	
�$�
$�'�$�7L�$�	
�$�
�!��,���	�

��!�	$�!�$�"�$��	$�


�$�#�	$�!�$�"�$��	$�


�$�$�!�$�"�$�

�	$��!��,���	�

�rYrc�>�eZdZdZdZd�Zd�Zd
d�Zdd�Zd�Z	dd	�Z
y)�NoCursorFetchStrategyz�Cursor strategy for a result that has no open cursor.

    There are two varieties of this strategy, one for DQL and one for
    DML (and also DDL), each of which represent a result that had a cursor
    but no longer has one.

    rzc��yrSrzrs   rWrz NoCursorFetchStrategy.soft_close����rYc��yrSrzrs   rWrz NoCursorFetchStrategy.hard_close�r,rYc�&�|j|d�SrS��_non_resultrs    rWrzNoCursorFetchStrategy.fetchone�s�������-�-rYNc�&�|j|g�SrSr/rs    rWrzNoCursorFetchStrategy.fetchmany���������+�+rYc�&�|j|g�SrSr/rs   rWrzNoCursorFetchStrategy.fetchall�r2rYc��t��rSr�rUr	�defaultr�s    rWr0z!NoCursorFetchStrategy._non_result�s��!�#�#rYr�rS)r�r�r�r�r�rrrrrr0rzrYrWr*r*�s,����I�
�
�.�,�,�$rYr*c��eZdZdZdZdd�Zy)�NoCursorDQLFetchStrategya�Cursor strategy for a DQL result that has no open cursor.

    This is a result set that can return rows, i.e. for a SELECT, or for an
    INSERT, UPDATE, DELETE that includes RETURNING. However it is in the state
    where the cursor is closed and no rows remain available.  The owning result
    object may or may not be "hard closed", which determines if the fetch
    methods send empty results or raise for closed result.

    rzNc�J�|jrtjd�|�|S)NzThis result object is closed.)�closedr�ResourceClosedErrorr5s    rWr0z$NoCursorDQLFetchStrategy._non_results)���=�=��)�)�/���
��NrYrS�r�r�r�r�r�r0rzrYrWr8r8�s����I�rYr8c��eZdZdZdZdd�Zy)�NoCursorDMLFetchStrategyz�Cursor strategy for a DML result that has no open cursor.

    This is a result set that does not return rows, i.e. for an INSERT,
    UPDATE, DELETE that does not include RETURNING.

    rzNc�j�|jjrJ�|jj|�yrS)�	_metadatarQ�_we_dont_return_rowsr5s    rWr0z$NoCursorDMLFetchStrategy._non_results+���#�#�0�0�0�0����-�-�c�2rYrSr<rzrYrWr>r>s����I�3rYr>c��eZdZdZdZ						dd�Z						dd�Z								dd�Z								d
d�Z	d							dd�Z		d							dd	�Z
						dd
�Zy)�CursorFetchStrategyz�Call fetch methods from a DBAPI cursor.

    Alternate versions of this class may instead buffer the rows from
    cursors or not use cursors at all.

    rzc��t|_yrS��_NO_CURSOR_DQL�cursor_strategyrs   rWrzCursorFetchStrategy.soft_close)���"0��rYc��t|_yrSrErs   rWrzCursorFetchStrategy.hard_close.rHrYc�V�|jj|dd||j�yrS)�
connection�_handle_dbapi_exceptionr�rs    rWrz$CursorFetchStrategy.handle_exception3s'��	���1�1���t�\�6�>�>�	
rYc�T�t|d|itj�d��|_y)N�max_row_bufferr)�initial_buffer�
growth_factor)�BufferedRowCursorFetchStrategy�collections�dequerGrs    rWrzCursorFetchStrategy.yield_per=s,��"@��
�s�#�&�,�,�.��	"
��rYc��	|j�}|�|j|��|S#t$r}|j|||�Yd}~yd}~wwxYw�N��hard)r�_soft_closer(r)rUr	r
r�rowr}s      rWrzCursorFetchStrategy.fetchoneJsU��	;��'�'�)�C��{��"�"�
�"�3��J���	;��!�!�&�,��:�:��	;�s�%(�	A�A	�	ANc���	|�|j�}n|j|�}|s|j�|S#t$r}|j|||�Yd}~yd}~wwxYwrS)rrXr(r)rUr	r
r�lr}s      rWrzCursorFetchStrategy.fetchmanyXsc��
	;��|� �*�*�,�� �*�*�4�0����"�"�$��H���	;��!�!�&�,��:�:��	;�s�7:�	A �A�A c��	|j�}|j�|S#t$r}|j|||�Yd}~yd}~wwxYwrS)rrXr(r)rUr	r
�rowsr}s     rWrzCursorFetchStrategy.fetchalljsK��
	;��(�(�*�D���� ��K���	;��!�!�&�,��:�:��	;�s�!$�	A
�A�A
r r'r#r�r$rSr%r&)r�r�r�r�r�rrrrrrrrzrYrWrCrCs����I�0�'�0�7L�0�	
�0�
0�'�0�7L�0�	
�0�

�!�
�,�
��	
�

�
�
�!�
�,�
��	
�

�
�"!�	;�!�;�"�;��	;�


�;�$#�	;�!�;�"�;��	;�


�;�$
;�!�
;�"�
;�

�	
;rYrCc�n��eZdZdZdZ		dd�Zed��Zd�Zd�Z	�fd�Z
�fd�Zd
d	�Zdd
�Z
d�Z�xZS)rQa�A cursor fetch strategy with row buffering behavior.

    This strategy buffers the contents of a selection of rows
    before ``fetchone()`` is called.  This is to allow the results of
    ``cursor.description`` to be available immediately, when
    interfacing with a DB-API that requires rows to be consumed before
    this information is available (currently psycopg2, when used with
    server-side cursors).

    The pre-fetching behavior fetches only one row initially, and then
    grows its buffer size by a fixed amount with each successive need
    for additional rows up the ``max_row_buffer`` size, which defaults
    to 1000::

        with psycopg2_engine.connect() as conn:

            result = conn.execution_options(
                stream_results=True, max_row_buffer=50
            ).execute(text("select * from table"))

    .. versionadded:: 1.4 ``max_row_buffer`` may now exceed 1000 rows.

    .. seealso::

        :ref:`psycopg2_execution_options`
    )�_max_row_buffer�
_rowbuffer�_bufsize�_growth_factorc��|jdd�|_|�||_n)tj|jd��|_||_|r&t|j|j�|_y|j|_y)NrNi�r)	�getr_r`rRrSrrb�minra)rUr
�execution_optionsrPrOs     rWr�z'BufferedRowCursorFetchStrategy.__init__�sv�� 1�4�4�5E�t�L����%�,�D�O�)�/�/��0F�0F�q�0I�J�D�O�+������ 4� 4�d�6I�6I�J�D�M� �0�0�D�MrYc�V�t|j|jj�SrS)rQ�cursorr�rf)r�r	s  rW�createz%BufferedRowCursorFetchStrategy.create�s#��-��M�M��N�N�,�,�
�	
rYc��|j}	|dkr|j�}n|j|�}sytj|�|_|jr9||jkr)t|j||jz�|_yyy#t$r}|j	|||�Yd}~��d}~wwxYw)z*this is currently used only by fetchone().rN)rarrr(rrRrSr`rbr_re)rUr	r
r�new_rowsr}s      rW�_buffer_rowsz+BufferedRowCursorFetchStrategy._buffer_rows�s����}�}��	;��a�x�'�0�0�2��'�1�1�$�7����%�+�+�H�5������4�$�*>�*>�#>���$�$�d�T�-@�-@�&@��D�M�$?���
�	;��!�!�&�,��:�:��	;�s�'B�	B>�!B9�9B>c�.�d|_|x|_|_yr�)rbr_rars    rWrz(BufferedRowCursorFetchStrategy.yield_per�s�����/2�2���t�}rYc�Z��|jj�t�|�
||�yrS�r`�clear�superr�rUr	r
r^s   �rWrz)BufferedRowCursorFetchStrategy.soft_close��"���������
���6�<�0rYc�Z��|jj�t�|�
||�yrS�r`rprqrrrs   �rWrz)BufferedRowCursorFetchStrategy.hard_close�rsrYc��|js2|j||�|js	|j|��y|jj�S#t$r}|j	|||�Yd}~yd}~wwxYwrU)r`rlrXr(r�popleft)rUr	r
rr}s     rWrz'BufferedRowCursorFetchStrategy.fetchone�s{��������f�l�3��?�?�C��&�&�J�&�7�����&�&�(�(��%�C��)�)�&�,��B�B���C�s�A�	A?�"A:�:A?c��|�|j||�S|j}t|�}d}||kDr,	|j||z
�}|sd}n|j	|�	tt|t|���D�	cgc]}	|j���}
}	|r|j�|
S#t
$r}|j
|||�Yd}~�nd}~wwxYwcc}	w)NFT)rr`rlr�extendr(rr�rerwrX)rUr	r
r�rb�lb�closer�r}r��ress           rWrz(BufferedRowCursorFetchStrategy.fetchmany�s����<��=�=���6�6�
�_�_��
��W�����"�9�	
#�"�,�,�T�B�Y�7��� �E��I�I�c�N�%*�3�t�S��W�+=�%>�?�%>��r�z�z�|�%>��?����� ��
��!�
?��%�%�f�l�A�>�>��
?��@s�B,�?C�,	C�5C
�
Cc��	t|j�t|j��z}|jj�|j	�|S#t
$r}|j
|||�Yd}~yd}~wwxYwrS)r�r`rrprXr(r)rUr	r
�retr}s     rWrz'BufferedRowCursorFetchStrategy.fetchall�sn��	;��t���'�$�|�/D�/D�/F�*G�G�C��O�O�!�!�#���� ��J���	;��!�!�&�,��:�:��	;�s�AA�	B�&A>�>B)r?Nr�rS)r�r�r�r�r�r�rrirlrrrrrr�
__classcell__�r^s@rWrQrQzsT����6P�I���1�(�
��
��(3�1�1�	)��0;rYrQc�V��eZdZdZdZ	d
d�Zd�Z�fd�Z�fd�Zdd�Z	dd�Z
d	�Z�xZS)
� FullyBufferedCursorFetchStrategyz�A cursor strategy that buffers rows fully upon creation.

    Used for operations where a result is to be delivered
    after the database conversation can not be continued,
    such as MSSQL INSERT...OUTPUT after an autocommit.

    )r`rc��||_|�tj|�|_ytj|j	��|_yrS)rrRrSr`r)rUr
�alternate_descriptionrOs    rWr�z)FullyBufferedCursorFetchStrategy.__init__s@��-B��)��%�)�/�/��?�D�O�)�/�/��0E�0E�0G�H�D�OrYc��yrSrzrs    rWrz*FullyBufferedCursorFetchStrategy.yield_perr,rYc�Z��|jj�t�|�
||�yrSrorrs   �rWrz+FullyBufferedCursorFetchStrategy.soft_closersrYc�Z��|jj�t�|�
||�yrSrurrs   �rWrz+FullyBufferedCursorFetchStrategy.hard_closersrYc�t�|jr|jj�S|j|��yrU)r`rwrXrs    rWrz)FullyBufferedCursorFetchStrategy.fetchones0���?�?��?�?�*�*�,�,����J��/�rYc���|�|j||�S|j}tt|t	|���D�cgc]}|j���}}|s|j
�|Scc}wrS)rr`r�rerlrwrX)rUr	r
rrzr�r]s       rWrz*FullyBufferedCursorFetchStrategy.fetchmany&sg���<��=�=���6�6�
�_�_��&+�C��c�"�g�,>�&?�@�&?���
�
��&?��@����� ����As�A.c�p�|j}tj�|_|j�|SrS)r`rRrSrX)rUr	r
rs    rWrz)FullyBufferedCursorFetchStrategy.fetchall0s,���o�o��%�+�+�-��������
rY)NNr�rS)
r�r�r�r�r�r�rrrrrrr�r�s@rWr�r�s:����?�I�HL�I�
�1�1���rYr�c�n�eZdZdZdZdd�Zd�Zd�Zd�Ze	d��Z
e	d	��Ze	d
��Ze	d��Z
y)
�_NoResultMetaDatarzFNc�.�tjd�|�)NzJThis result object does not return rows. It has been closed automatically.)rr;)rUr�s  rWrAz&_NoResultMetaData._we_dont_return_rows<s���%�%�
0�
��	rYc�$�|j�yrS�rA)rUrcr�s   rWr�z _NoResultMetaData._index_for_keyB����!�!�#rYc�$�|j�yrSr�rTs  rWr�z$_NoResultMetaData._metadata_for_keysEr�rYc�$�|j�yrSr�)rUrcs  rWr�z_NoResultMetaData._reduceHr�rYc�$�|j�yrSr��rUs rWrEz_NoResultMetaData._keymapK����!�!�#rYc�$�|j�yrSr�r�s rWrMz_NoResultMetaData._key_to_indexOr�rYc�$�|j�yrSr�r�s rWrFz_NoResultMetaData._processorsSr�rYc�$�|j�yrSr�r�s rWrcz_NoResultMetaData.keysWr�rYrS)r�r�r�r�rQrAr�r�r��propertyrErMrFrcrzrYrWr�r�7sp���I��L��$�$�$��$��$��$��$��$��$��$��$rYr�c�`�tt�tg��}|j�|SrS)rr��iterrX)�its rW�null_dml_resultr�_s%��,�->�-@�$�r�(�K�B��N�N��
�IrYc���eZdZUdZdZded<eZdZded<dZ	ded<d	Z
d
ed<ded
<ded<ded<						d/d�Zd�Zd0d�Z
ed��Zed��Zd�Zd�Zed��Zd�Zd�Zd�Zed��Zd�Zd�Zd �Zd!�Zd"�Zej<d1d#��Zed$��Z ed%��Z!ed&��Z"d'�Z#d0d(�Z$d)�Z%d2d*�Z&d+�Z'd3�fd,�Z(d4d-�Z)e*d5d.��Z+�xZ,S)6�CursorResulta+A Result that is representing state from a DBAPI cursor.

    .. versionchanged:: 1.4  The :class:`.CursorResult``
       class replaces the previous :class:`.ResultProxy` interface.
       This classes are based on the :class:`.Result` calling API
       which provides an updated usage model and calling facade for
       SQLAlchemy Core and SQLAlchemy ORM.

    Returns database rows via the :class:`.Row` class, which provides
    additional API features and behaviors on top of the raw data returned by
    the DBAPI.   Through the use of filters such as the :meth:`.Result.scalars`
    method, other kinds of objects may also be returned.

    .. seealso::

        :ref:`tutorial_selecting_data` - introductory material for accessing
        :class:`_engine.CursorResult` and :class:`.Row` objects.

    )r�r�rhrG�_echorKz.Union[CursorResultMetaData, _NoResultMetaData]r@FrO�_soft_closedr:Tr*r�r-r�rrGr)rKc���	�
���
�||_|j|_|j|_||_|j|_|j
jxr|jj�x|_}|��|j||�}tjt||j|j��
|jr2t!j"t%|j����
�fd�}|�
n�
�
|r5|jj
j&��fd��	�	|_�	�
fd�}|}n�
}|j+d|�y|jdk(sJ�|j,|_y)Nc� ����|��SrSrz)�raw_data�	_make_row�sentinel_filters ��rW�_sliced_rowz*CursorResult.__init__.<locals>._sliced_row�s���$�_�X�%>�?�?rYc�@���dtj|��|S)NzRow %r)�sql_util�	_repr_row)rY�logs �rW�_log_rowz'CursorResult.__init__.<locals>._log_row�s�����(�"4�"4�S�"9�:��JrYc� ����|��SrSrz)rYr��
sliced_rows ��rW�_make_row_2z*CursorResult.__init__.<locals>._make_row_2�s���#�J�s�O�4�4rY�_row_getterr)r�r�rhrG�root_connectionrKr��engine�_should_log_debug�_init_metadata�	functools�partialr�_effective_processorsrM�_num_sentinel_cols�operator�
itemgetter�slice�
_log_debug�_row_logging_fn�_set_memoized_attribute�_no_result_metadatar@)rUr�rGr��echo�metadatar�r��make_rowr�r�r�r�r�s         @@@@@rWr�zCursorResult.__init__�sQ������������n�n���.���!�1�1����O�O�!�!�H�g�n�n�&F�&F�&H�	
��
�T��)�
�*�*�7�4F�G�H�"�)�)����.�.��&�&�	�I��)�)�"*�"5�"5��7�5�5�5�6�#��@�)�
�&�
���l�l�-�-�8�8���(0��$�5�'��%���(�(���A��-�-��2�2�2�!�5�5�D�NrYc�2�|jr�|j}|jr
|j}nt||�}|jr||_|jjdd�sW|jrK|j|jjur)|j|jur|j|�}||_
nt||�x|_
}|jr,|jj!dt#d�|D���|S)N� _result_disable_adapt_to_contextFzCol %rc3�&K�|]	}|d���y�w)rNrz)r{r�s  rWr~z.CursorResult._init_metadata.<locals>.<genexpr>�s����A�.@���!��.@�s�)r��_cached_metadatarDrKrfrdr��	cache_hitr��	CACHE_HITr�r�r�r@r�rKr��tuple)rUr�r�r�r�s     rWr�zCursorResult._init_metadata�s������'�'�H��(�(�#�4�4��/��6H�I���+�+�08�H�-�"�-�-�1�1�6����,�,��%�%����)B�)B�B��&�&�g�.G�.G�G�#�5�5�g�>��%�D�N�)=��(�)�
�D�N�X��:�:����)�)��%�A�.@�A�A�
��rYc�n�|s|js|r
|jry|r.d|_|jj||j�n&|jj||j�|js6|j}d|_|jj|�d|_yy)a\Soft close this :class:`_engine.CursorResult`.

        This releases all DBAPI cursor resources, but leaves the
        CursorResult "open" from a semantic perspective, meaning the
        fetchXXX() methods will continue to return empty results.

        This method is called automatically when:

        * all result rows are exhausted using the fetchXXX() methods.
        * cursor.description is None.

        This method is **not public**, but is documented in order to clarify
        the "autoclose" process used.

        .. seealso::

            :meth:`_engine.CursorResult.close`


        NT)r�r:rGrrhrrK�_safe_close_cursor)rUrWrhs   rWrXzCursorResult._soft_close�s���,��*�*��������D�K�� � �+�+�D�$�+�+�>�� � �+�+�D�$�+�+�>�� � ��[�[�F��D�K��O�O�.�.�v�6� $�D��	!rYc�0�|jjstjd��|jjstjd��|jj
rtjd��|jjS)a�Return the value of
        :attr:`_engine.CursorResult.inserted_primary_key`
        as a row contained within a list; some dialects may support a
        multiple row form as well.

        .. note:: As indicated below, in current SQLAlchemy versions this
           accessor is only useful beyond what's already supplied by
           :attr:`_engine.CursorResult.inserted_primary_key` when using the
           :ref:`postgresql_psycopg2` dialect.   Future versions hope to
           generalize this feature to more dialects.

        This accessor is added to support dialects that offer the feature
        that is currently implemented by the :ref:`psycopg2_executemany_mode`
        feature, currently **only the psycopg2 dialect**, which provides
        for many rows to be INSERTed at once while still retaining the
        behavior of being able to return server-generated primary key values.

        * **When using the psycopg2 dialect, or other dialects that may support
          "fast executemany" style inserts in upcoming releases** : When
          invoking an INSERT statement while passing a list of rows as the
          second argument to :meth:`_engine.Connection.execute`, this accessor
          will then provide a list of rows, where each row contains the primary
          key value for each row that was INSERTed.

        * **When using all other dialects / backends that don't yet support
          this feature**: This accessor is only useful for **single row INSERT
          statements**, and returns the same information as that of the
          :attr:`_engine.CursorResult.inserted_primary_key` within a
          single-element list. When an INSERT statement is executed in
          conjunction with a list of rows to be INSERTed, the list will contain
          one row per row inserted in the statement, however it will contain
          ``None`` for any server-generated values.

        Future releases of SQLAlchemy will further generalize the
        "fast execution helper" feature of psycopg2 to suit other dialects,
        thus allowing this accessor to be of more general use.

        .. versionadded:: 1.4

        .. seealso::

            :attr:`_engine.CursorResult.inserted_primary_key`

        �1Statement is not a compiled expression construct.�2Statement is not an insert() expression construct.z9Can't call inserted_primary_key when returning() is used.)r�r�rr��isinsert�_is_explicit_returning�inserted_primary_key_rowsr�s rWr�z&CursorResult.inserted_primary_key_rows!s���\�|�|�$�$��)�)�C��
����&�&��)�)�D��
��\�\�
0�
0��)�)���
�
�|�|�5�5�5rYc��|jjrtjd��|j}|r|dSy)a�Return the primary key for the row just inserted.

        The return value is a :class:`_result.Row` object representing
        a named tuple of primary key values in the order in which the
        primary key columns are configured in the source
        :class:`_schema.Table`.

        .. versionchanged:: 1.4.8 - the
           :attr:`_engine.CursorResult.inserted_primary_key`
           value is now a named tuple via the :class:`_result.Row` class,
           rather than a plain tuple.

        This accessor only applies to single row :func:`_expression.insert`
        constructs which did not explicitly specify
        :meth:`_expression.Insert.returning`.    Support for multirow inserts,
        while not yet available for most backends, would be accessed using
        the :attr:`_engine.CursorResult.inserted_primary_key_rows` accessor.

        Note that primary key columns which specify a server_default clause, or
        otherwise do not qualify as "autoincrement" columns (see the notes at
        :class:`_schema.Column`), and were generated using the database-side
        default, will appear in this list as ``None`` unless the backend
        supports "returning" and the insert statement executed with the
        "implicit returning" enabled.

        Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
        statement is not a compiled expression construct
        or is not an insert() construct.

        zuThis statement was an executemany call; if primary key returning is supported, please use .inserted_primary_key_rows.rN)r��executemanyrr�r�)rU�ikps  rW�inserted_primary_keyz!CursorResult.inserted_primary_key_sF��B�<�<�#�#��)�)�2��
��,�,����q�6�M�rYc�8�|jjstjd��|jjstjd��|jj
r|jjS|jjdS)aReturn the collection of updated parameters from this
        execution.

        Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
        statement is not a compiled expression construct
        or is not an update() construct.

        r�z2Statement is not an update() expression construct.r)r�r�rr��isupdater��compiled_parametersr�s rW�last_updated_paramsz CursorResult.last_updated_params�����|�|�$�$��)�)�C��
����&�&��)�)�D��
��\�\�
%�
%��<�<�3�3�3��<�<�3�3�A�6�6rYc�8�|jjstjd��|jjstjd��|jj
r|jjS|jjdS)aReturn the collection of inserted parameters from this
        execution.

        Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
        statement is not a compiled expression construct
        or is not an insert() construct.

        r�r�r)r�r�rr�r�r�r�r�s rW�last_inserted_paramsz!CursorResult.last_inserted_params�r�rYc�.�|jjS)aReturn a list of rows each containing the values of default
        columns that were fetched using
        the :meth:`.ValuesBase.return_defaults` feature.

        The return value is a list of :class:`.Row` objects.

        .. versionadded:: 1.4

        )r��returned_default_rowsr�s rW�returned_defaults_rowsz#CursorResult.returned_defaults_rows�s���|�|�1�1�1rYc��|j�}tt|j��t|j���D��cgc]\}}t	|�t	|�z��}}}|j
j
|j
�|_td|��|_|j�|Scc}}w)akReturn a new :class:`.CursorResult` that "horizontally splices"
        together the rows of this :class:`.CursorResult` with that of another
        :class:`.CursorResult`.

        .. tip::  This method is for the benefit of the SQLAlchemy ORM and is
           not intended for general use.

        "horizontally splices" means that for each row in the first and second
        result sets, a new row that concatenates the two rows together is
        produced, which then becomes the new row.  The incoming
        :class:`.CursorResult` must have the identical number of rows.  It is
        typically expected that the two result sets come from the same sort
        order as well, as the result rows are spliced together based on their
        position in the result.

        The expected use case here is so that multiple INSERT..RETURNING
        statements (which definitely need to be sorted) against different
        tables can produce a single result that looks like a JOIN of those two
        tables.

        E.g.::

            r1 = connection.execute(
                users.insert().returning(
                    users.c.user_name, users.c.user_id, sort_by_parameter_order=True
                ),
                user_values,
            )

            r2 = connection.execute(
                addresses.insert().returning(
                    addresses.c.address_id,
                    addresses.c.address,
                    addresses.c.user_id,
                    sort_by_parameter_order=True,
                ),
                address_values,
            )

            rows = r1.splice_horizontally(r2).all()
            assert rows == [
                ("john", 1, 1, "foo@bar.com", 1),
                ("jack", 2, 2, "bar@bat.com", 2),
            ]

        .. versionadded:: 2.0

        .. seealso::

            :meth:`.CursorResult.splice_vertically`


        N�rO)
�	_generate�zipr��_raw_row_iteratorr�r@rwr�rG�_reset_memoizations)rUrt�clone�r1�r2�
total_rowss      rW�splice_horizontallyz CursorResult.splice_horizontally�s���n��� ����T�+�+�-�.��U�,�,�.�/��
����B�
�"�I��b�	�!��	�
� �/�/�>�>�u���O��� @��%�!
���	�!�!�#����
s�!Cc���|j�}t|j��t|j��z}td|��|_|j�|S)a�Return a new :class:`.CursorResult` that "vertically splices",
        i.e. "extends", the rows of this :class:`.CursorResult` with that of
        another :class:`.CursorResult`.

        .. tip::  This method is for the benefit of the SQLAlchemy ORM and is
           not intended for general use.

        "vertically splices" means the rows of the given result are appended to
        the rows of this cursor result. The incoming :class:`.CursorResult`
        must have rows that represent the identical list of columns in the
        identical order as they are in this :class:`.CursorResult`.

        .. versionadded:: 2.0

        .. seealso::

            :meth:`.CursorResult.splice_horizontally`

        Nr�)r�r�r�r�rGr�)rUrtr�r�s    rW�splice_verticallyzCursorResult.splice_verticallysd��(��� ���$�0�0�2�3�d��#�#�%�7
�
�
�!A��%�!
���	�!�!�#��rYc��|jr/|jjjdt	|��tt|j�j�|_td|��|_
|j�|S)arewind this result back to the given rowset.

        this is used internally for the case where an :class:`.Insert`
        construct combines the use of
        :meth:`.Insert.return_defaults` along with the
        "supplemental columns" feature.

        zCursorResult rewound %d row(s)Nr�)r�r�rKr�rlrrDr@ror�rGr��rUr]s  rW�_rewindzCursorResult._rewind/sz���:�:��L�L�#�#�.�.�0�#�d�)�
�� �$�.�.�
�
�
�
�	
�� @�� � 
���	
� � �"��rYc��|jjrtjd��|jj}|r|dSy)axReturn the values of default columns that were fetched using
        the :meth:`.ValuesBase.return_defaults` feature.

        The value is an instance of :class:`.Row`, or ``None``
        if :meth:`.ValuesBase.return_defaults` was not used or if the
        backend does not support RETURNING.

        .. seealso::

            :meth:`.ValuesBase.return_defaults`

        zlThis statement was an executemany call; if return defaults is supported, please use .returned_defaults_rows.rN)r�r�rr�r�r�s  rW�returned_defaultszCursorResult.returned_defaultsOsJ���<�<�#�#��)�)�D��
�
�|�|�1�1�����7�N�rYc�6�|jj�S)z�Return ``lastrow_has_defaults()`` from the underlying
        :class:`.ExecutionContext`.

        See :class:`.ExecutionContext` for details.

        )r��lastrow_has_defaultsr�s rWr�z!CursorResult.lastrow_has_defaultsjs���|�|�0�0�2�2rYc��|jjstjd��|jjs+|jj
stjd��|jjS)aMReturn ``postfetch_cols()`` from the underlying
        :class:`.ExecutionContext`.

        See :class:`.ExecutionContext` for details.

        Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
        statement is not a compiled expression construct
        or is not an insert() or update() construct.

        r��>Statement is not an insert() or update() expression construct.)r�r�rr�r�r��postfetch_colsr�s rWr�zCursorResult.postfetch_colstsl���|�|�$�$��)�)�C��
����&�&�t�|�|�/D�/D��)�)�(��
��|�|�*�*�*rYc��|jjstjd��|jjs+|jj
stjd��|jjS)aLReturn ``prefetch_cols()`` from the underlying
        :class:`.ExecutionContext`.

        See :class:`.ExecutionContext` for details.

        Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
        statement is not a compiled expression construct
        or is not an insert() or update() construct.

        r�r�)r�r�rr�r�r��
prefetch_colsr�s rWr�zCursorResult.prefetch_cols�sl���|�|�$�$��)�)�C��
����&�&�t�|�|�/D�/D��)�)�(��
��|�|�)�)�)rYc�.�|jjS)z�Return ``supports_sane_rowcount`` from the dialect.

        See :attr:`_engine.CursorResult.rowcount` for background.

        )r��supports_sane_rowcountr�s rWr�z#CursorResult.supports_sane_rowcount�s���|�|�2�2�2rYc�.�|jjS)z�Return ``supports_sane_multi_rowcount`` from the dialect.

        See :attr:`_engine.CursorResult.rowcount` for background.

        )r��supports_sane_multi_rowcountr�s rWr�z)CursorResult.supports_sane_multi_rowcount�s���|�|�8�8�8rYc��	|jjS#t$r-}|jj	||j
|��d}~wwxYw)aReturn the 'rowcount' for this result.

        The primary purpose of 'rowcount' is to report the number of rows
        matched by the WHERE criterion of an UPDATE or DELETE statement
        executed once (i.e. for a single parameter set), which may then be
        compared to the number of rows expected to be updated or deleted as a
        means of asserting data integrity.

        This attribute is transferred from the ``cursor.rowcount`` attribute
        of the DBAPI before the cursor is closed, to support DBAPIs that
        don't make this value available after cursor close.   Some DBAPIs may
        offer meaningful values for other kinds of statements, such as INSERT
        and SELECT statements as well.  In order to retrieve ``cursor.rowcount``
        for these statements, set the
        :paramref:`.Connection.execution_options.preserve_rowcount`
        execution option to True, which will cause the ``cursor.rowcount``
        value to be unconditionally memoized before any results are returned
        or the cursor is closed, regardless of statement type.

        For cases where the DBAPI does not support rowcount for a particular
        kind of statement and/or execution, the returned value will be ``-1``,
        which is delivered directly from the DBAPI and is part of :pep:`249`.
        All DBAPIs should support rowcount for single-parameter-set
        UPDATE and DELETE statements, however.

        .. note::

           Notes regarding :attr:`_engine.CursorResult.rowcount`:


           * This attribute returns the number of rows *matched*,
             which is not necessarily the same as the number of rows
             that were actually *modified*. For example, an UPDATE statement
             may have no net change on a given row if the SET values
             given are the same as those present in the row already.
             Such a row would be matched but not modified.
             On backends that feature both styles, such as MySQL,
             rowcount is configured to return the match
             count in all cases.

           * :attr:`_engine.CursorResult.rowcount` in the default case is
             *only* useful in conjunction with an UPDATE or DELETE statement,
             and only with a single set of parameters. For other kinds of
             statements, SQLAlchemy will not attempt to pre-memoize the value
             unless the
             :paramref:`.Connection.execution_options.preserve_rowcount`
             execution option is used.  Note that contrary to :pep:`249`, many
             DBAPIs do not support rowcount values for statements that are not
             UPDATE or DELETE, particularly when rows are being returned which
             are not fully pre-buffered.   DBAPIs that dont support rowcount
             for a particular kind of statement should return the value ``-1``
             for such statements.

           * :attr:`_engine.CursorResult.rowcount` may not be meaningful
             when executing a single statement with multiple parameter sets
             (i.e. an :term:`executemany`). Most DBAPIs do not sum "rowcount"
             values across multiple parameter sets and will return ``-1``
             when accessed.

           * SQLAlchemy's :ref:`engine_insertmanyvalues` feature does support
             a correct population of :attr:`_engine.CursorResult.rowcount`
             when the :paramref:`.Connection.execution_options.preserve_rowcount`
             execution option is set to True.

           * Statements that use RETURNING may not support rowcount, returning
             a ``-1`` value instead.

        .. seealso::

            :ref:`tutorial_update_delete_rowcount` - in the :ref:`unified_tutorial`

            :paramref:`.Connection.execution_options.preserve_rowcount`

        N)r��rowcountr(rGrrh�rUr}s  rWr�zCursorResult.rowcount�sG��X	��<�<�(�(�(���	�� � �1�1�$����Q�G���	�s��	A�(A	�	Ac��	|jj�S#t$r1}|jj	||j
|�Yd}~yd}~wwxYw)a0Return the 'lastrowid' accessor on the DBAPI cursor.

        This is a DBAPI specific method and is only functional
        for those backends which support it, for statements
        where it is appropriate.  It's behavior is not
        consistent across backends.

        Usage of this method is normally unnecessary when
        using insert() expression constructs; the
        :attr:`~CursorResult.inserted_primary_key` attribute provides a
        tuple of primary key values for a newly inserted row,
        regardless of database backend.

        N)r��
get_lastrowidr(rGrrhrs  rW�	lastrowidzCursorResult.lastrowidsL�� 	H��<�<�-�-�/�/���	H�� � �1�1�$����Q�G�G��	H�s��	A�'A�Ac�.�|jjS)aqTrue if this :class:`_engine.CursorResult` returns zero or more
        rows.

        I.e. if it is legal to call the methods
        :meth:`_engine.CursorResult.fetchone`,
        :meth:`_engine.CursorResult.fetchmany`
        :meth:`_engine.CursorResult.fetchall`.

        Overall, the value of :attr:`_engine.CursorResult.returns_rows` should
        always be synonymous with whether or not the DBAPI cursor had a
        ``.description`` attribute, indicating the presence of result columns,
        noting that a cursor that returns zero rows still has a
        ``.description`` if a row-returning statement was emitted.

        This attribute should be True for all results that are against
        SELECT statements, as well as for DML statements INSERT/UPDATE/DELETE
        that use RETURNING.   For INSERT/UPDATE/DELETE statements that were
        not using RETURNING, the value will usually be False, however
        there are some dialect-specific exceptions to this, such as when
        using the MSSQL / pyodbc dialect a SELECT is emitted inline in
        order to retrieve an inserted primary key value.


        )r@rQr�s rWrQzCursorResult.returns_rowss��4�~�~�*�*�*rYc�.�|jjS)alTrue if this :class:`_engine.CursorResult` is the result
        of a executing an expression language compiled
        :func:`_expression.insert` construct.

        When True, this implies that the
        :attr:`inserted_primary_key` attribute is accessible,
        assuming the statement did not include
        a user defined "returning" construct.

        )r�r�r�s rW�	is_insertzCursorResult.is_insert7s���|�|�$�$�$rYc#�nK�|jj}	|||j�}|�y|����wrS�rGrrh)rUrrYs   rW�_fetchiter_implzCursorResult._fetchiter_implEs<�����'�'�0�0����4����-�C��{���I�	�s�35c�P�|jj||j|�SrSr)rUrs  rW�_fetchone_implzCursorResult._fetchone_implNs!���#�#�,�,�T�4�;�;�
�K�KrYc�N�|jj||j�SrS)rGrrhr�s rW�_fetchall_implzCursorResult._fetchall_implQs���#�#�,�,�T�4�;�;�?�?rYc�P�|jj||j|�SrS)rGrrh)rUrs  rW�_fetchmany_implzCursorResult._fetchmany_implTs!���#�#�-�-�d�D�K�K��F�FrYc�"�|j�SrS)r	r�s rWr�zCursorResult._raw_row_iteratorWs���#�#�%�%rYc���t�|�|�}|jjrt	d�|f|zD��|_|S)Nc3�HK�|]}td|�j���y�w)r�N)rr�)r{r	s  rWr~z%CursorResult.merge.<locals>.<genexpr>]s&����)�.�F��(�&�1�:�:�.�r)rq�merger��
_has_rowcount�sumr�)rU�others�
merged_resultr^s   �rWrzCursorResult.mergeZsG�����
�v�.�
��<�<�%�%�%(�)�#�g��.�)�&�M�"��rYc�(�|jd��y)a�Close this :class:`_engine.CursorResult`.

        This closes out the underlying DBAPI cursor corresponding to the
        statement execution, if one is still present.  Note that the DBAPI
        cursor is automatically released when the :class:`_engine.CursorResult`
        exhausts all available rows.  :meth:`_engine.CursorResult.close` is
        generally an optional method except in the case when discarding a
        :class:`_engine.CursorResult` that still has additional rows pending
        for fetch.

        After this method is called, it is no longer valid to call upon
        the fetch methods, which will raise a :class:`.ResourceClosedError`
        on subsequent use.

        .. seealso::

            :ref:`connections_toplevel`

        TrVN)rXr�s rWr|zCursorResult.closecs��(	
���d��#rYc�b�||_|jj||j|�|SrS)�
_yield_perrGrrh)rUrs  rWrzCursorResult.yield_perys*��������&�&�t�T�[�[�#�>��rY)r�r*rGrr�rr�)r�r�rS)rzResult[Any]r�zMergedResult[Any])r�r)rr�r�r()-r�r�r�r�r�r��_NO_RESULT_METADATAr�r�r:�
_is_cursorr�r�rXr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�memoized_propertyr�rrQrr	rr
rr�rr|rrr�r�s@rWr�r�es�����(�I�>�=�-���L�$���F�D���J�
$�$�
��(�(���=6�(�=6�-�=6�>�	=6�~-�^#%�J�;6��;6�z�+��+�Z7�,7�,�
2��
2�G�R�@�@����43�+�.*�.3�9�
���O��O�b�H��H�(�+��+�6�%��%��L�@�G�&��$�,���rYr�)r�zIteratorResult[Any])ar��
__future__rrRr�r��typingrrrrrr	r
rrr
rrrrr	rrrrrrrYr�rr�sqlrrr��sql.baser�sql.compilerr r!r"r#r$�sql.type_apir%r&�util.typingr'r(�baser)r6r*�
interfacesr+r,r-r.r/r0r1r2r3r4r5r6r8r�r9r:r<r>r@rBr�r��_CursorKeyMapRecTyperNr�rDrr*r8rFr>�_NO_CURSOR_DMLrC�_DEFAULT_FETCHrQr�r�rr�r��ResultProxyrzrYrW�<module>r,sy���#����
������������ ���"� ��"�(�������"�"�-�"�%�+�"�%��!��
��� �0�3�'�#�,�%�&�#� �'�(�3�
�T������*���#$��Z�#�/��
�J����
�z��� !��*� ����j��3�����&���S�M����I����
(�)��S�M�
����J�(<�<�=�� %�����I����
(�)��
	� ��F@�>�F@�R;�;�|$�/�$�<�4��,*�+��
3�4�
3� *�+��U;�-�U;�p%�&��C;�%8�C;�L4�':�4�n"$��"$�J(�)���X�6�"�:�X�v�rY

ZeroDay Forums Mini