Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
cursor.cpython-313.pyc840 linesDownload Raw Back to __pycache__
1�

2��j�D�	�6�%SrSSKJr SSKrSSKrSSKrSSKrSSKJr SSKJr SSKJ	r	 SSKJ3r4 SSKJr SS	KJr SS5KJ
r
 SSKJr SSKJr SS
KJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSK J!r! SSK J"r" SSK#J$r$ SS K#J%r% SSK#J"r& SS!K'J(r( SS"K)J*r* SS#K)J+r+ SS$K)J,r, SS%K)J-r- SS&K)J.r. SS'K/J0r0 SS(K"J1r1 SS)K2J3r3 SS*K2J4r4 SS+K2J5r5 \R((afSS,K6J7r7 SS-K8J9r9 SS.K:J;r; SS/K:J<r< SS0K:J=r= SS1K:J>r> SS2K:J?r? SS3K:J@r@ SS4K:JArA SS5KJBrB SS6KJCrC SS7KJDrD SS8KJErE SS9KJFrF SS:KJGrG SS;KHJIrI SS<K/JJrJ \"S=\S>9rK\\S?4rLSrMS@\NSA'SrOSB\NSC'SrPSD\NSE'SFrQSG\NSH'SIrRSJ\NSK'SLrSSM\NSN'SOrTSP\NSQ'\\\U\U\L\V\V\SR\\V4rW\SS\W4rX\\U\U\\\V\V\SR\V4rY\\U\\U\V\0\ST\\L\\V4rZ"SUSV\5r["SWSX5r\"SYSZ\\5r]"S[S\\]5r^\^"5r_"S]S^\]5r`\`"5ra"S_S`\\5rb\b"5rc"SaSb\b5rd"ScSd\b5re"SeSf\5rf\f"5rgSjSgjrh"ShSi\\K5ri\irjg)kzNDefine cursor-specific result set constructs including6:class:`.CursorResult`.�)�annotationsN)�Any)�cast)�ClassVar)�Deque)�Dict)�Iterable)�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)�7RM_OBJECTS)�RM_RENDERED_NAME)�RM_TYPE)�8TypeEngine)�compat)�Final)�Literal)�Self)�9Connection)�DefaultExecutionContext)�_DBAPICursorDescription)�_MutableCoreSingleExecuteParams)�CoreExecuteOptionsParameter)�DBAPICursor)�	DBAPIType)�Dialect)�ExecutionContext)�
_KeyIndexType)�_KeyMapRecType)�_KeyMapType)�_KeyType)�_ProcessorsType)�_TupleGetterType)�Column)�_ResultProcessorType�_T)�bound.zFinal[Literal[0]]�MD_INDEXzFinal[Literal[1]]�MD_RESULT_MAP_INDEXzFinal[Literal[2]]�10MD_OBJECTS�zFinal[Literal[3]]�
MD_LOOKUP_KEY�zFinal[Literal[4]]�MD_RENDERED_NAME�zFinal[Literal[5]]�MD_PROCESSOR�zFinal[Literal[6]]�MD_UNTRANSLATEDz_ResultProcessorType[Any]r8r2c�2�\rSrSr%SrSrS\S'S\S'S\S	'S11\S'S12\S'S
\S'SrS\S'S)SjrS*Sjr	S+Sjr13S,SjrS-SjrS.Sjr
S/SjrS0SjrS1SjrS2SjrS3SjrS4Sjr\S5S6Sjj5rS7Sjr\(dS8S9S jjrS:S!jrS8S;S"jjrS<S#jrS=S$jrS>S%jrS?S&jrS'rg()@�CursorResultMetaData�z"Result metadata for DBAPI cursors.)	�_keymap�_processors�_keys�_keymap_by_result_column_idx�_tuplefilter�_translated_indexes�_safe_for_cache�14_unpickled�
_key_to_index�_CursorKeyMapTyperMr9rNz#Optional[Dict[int, _KeyMapRecType]]rP�boolrTrS�Optional[List[int]]rRTzClassVar[bool]�returns_rowsc��XR;$�N)rM��self�keys  �^D:\code\apps\devtools\python\user_packages\Python313\site-packages\sqlalchemy/engine/cursor.py�_has_key�CursorResultMetaData._has_key�s���l�l�"�"�c��[URURVs/sHoRU[PM snS9$s snf)N)�extra)rrOrMrAr\s  r_�_for_freeze� CursorResultMetaData._for_freeze�s;��#��J�J�<@�J�J�G�J�S�<�<��$�Z�0�J�G�15�	16��Gs�A17c���URRUR5n	XlX)lX9lXIlXYlXilXylX�l	URU[5U	lU	$r[)
�	__class__�__new__rTrNrOrMrQrRrSrP�_make_key_to_indexr?rU)18r]�	unpickled�19processors�keys�keymap�tuplefilter�translated_indexes�safe_for_cache�keymap_by_result_column_idx�new_objs20          r_�_make_new_metadata�'CursorResultMetaData._make_new_metadata�sd���.�.�(�(����8��&��(���
� ��*��&8�#�"0��/J�,� $� 7� 7��� I����rbc�P�UR(aeURURS/[UR5-SSUR21R
5VVs0sHupXSSS-USS-_M snnURURURS9$s snnf)NrrFr[rH)rkrlrorprnrmrqrr)22rQrtrT�lenrNrM�itemsrOrSrP)r]r^�values   r_�_remove_processors�'CursorResultMetaData._remove_processors�s����$�$�$�$��&�&��o�o��v��D�$4�$4� 5�5��#�#'�,�,�"4�"4�"6��"6�J�C��1�Q�Z�'�)�E�!�"�I�5�5�"6������/�/�(,�(I�(I�'�23�	24��25s�!B"c�8�UR(ae[UR5n[UR5nURR5H<upEU[bXB;aU[U-nU[U-nOSnSnXg/USSQ7X$'M> URURURUR-SSURUR-UURUR5Vs0sH
nU[U_M snS9$s snf)N�����r)rkrlrorprmrnrqrr)
rQ�dictrMrwrOrxr?r@rtrTrNrS�values)	r]�otherrn�offsetr^ry�md_index�	md_object�metadata_entrys	         r_�_splice_horizontally�)CursorResultMetaData._splice_horizontally�s���$�$�$�$��d�l�l�#���T�Z�Z����-�-�-�-�/�J�C��X��*�s�/@� ��?�V�3��!�"5�6��?�	����	�#�;��q�r��;�F�K�0��&�&��o�o��'�'�%�*;�*;�;��#����e�k�k�)���/�/�'-�m�m�o�)�&5�N��2�3�^�C�&5�)�'�26�	27��)s�>Dc�b�[URU55nUVs/sHo3[PM
 nnUVs/sHo3[PM
 nnUR(aUVs/sHo`RUPM nn[U6n[
U5VVs/sHup�U4USS-PM n	nnU	Vs0sHo3[U_M n28nU29RSU	55 URURURUUUU30URURS9$s snfs snfs snfs snnfs snf)Nrc3�\# �UH"nU[=(d SHnX!4v� M31 M$ g7f)�N)rA)�.0�new_rec�es   r_�	<genexpr>�/CursorResultMetaData._reduce.<locals>.<genexpr>s3���32�#���Z�(�.�B�.���L�.�
�#�s�*,)rkrlrmrorprnrqrr)
�list�_metadata_for_keysr?rCrRr�	enumerate�updatertrTrNrSrP)r]rm�recs�rec�indexes�new_keys�idx�tup�index�new_recsrns           r_�_reduce�CursorResultMetaData._reduce	s.���D�+�+�D�1�2��,0�1�D�S�x�=�D��1�=A�B�T�c�=�1�T��B��#�#�@G�H���/�/��4��G�H��7�#��9B�4��I��:�5�U�H�s�1�2�w�&���I�5=�>�X�c�m�$�c�)�X��>�	�
�
�33�#�34�	35��&�&��o�o��'�'���&���/�/�(,�(I�(I�'�	36�		37��%2��B��I��I��>s�D�D� D!�D&�,D,c��UR(aURR(dU$URRnURn[(a![U[R5(deX#LaU$UceURnUc9URR5Vs0sH
nU[U_M sn=o@lUR(aeUR[R"UR[!UR"5VVs0sHupgXd;dMXtU_M snn5UR$UR&SSUR(UR*URS9$s snfs snnf)a3When using a cached Compiled construct that has a _result_map,38for a new statement that used the cached Compiled, we need to ensure39the keymap has the Column objects from our new statement as keys.40So here we rewrite keymap with new entries for the new columns41as matched to those of the cached statement.42 43N)rnrkrlrorprmrqrr)�compiled�_result_columns�	statement�invoked_statementr�44isinstancer�
ClauseElementrPrMrr@rQrtr(�45dict_unionr��_all_selected_columnsrTrNrOrS)r]�context�compiled_statementr��keymap_by_positionr�r��news        r_�_adapt_to_context�&CursorResultMetaData._adapt_to_context)s������w�'7�'7�'G�'G��K�$�-�-�7�7��#�5�5���=��/��1G�1G�H�H�H�H��2��K� �,�,�,�"�>�>���%�46'+�l�l�&9�&9�&;�F�&;�N��2�3�^�C�&;�F�
��!B�47�$�$�$�$��&�&��$�$����%.�)�?�?�%��%����0�	1�C�C�0�0�%��	��o�o��'�'��#�����/�/�(,�(I�(I�#'�48�	49��
F��s�3E<�!F�0	Fc
��URnSUlSUlS=UlUlUR50(aUR51unnnnn[
U5n	OS=n=n=n	=n=nnURUUUU	UUUU5n52U53Vs/sHo�[PM
 snUl	SUl54U	(GaZU55Vs0sH
nU[U_M nn[
U5U	:wa�0n
[5nU56HYnU[4U[=(d S-H5nU[nU
R!UU5U:wdM$UR#U5 M7 M[ U57VVs0sH/nU[(dMU[HnUU;dMUU_M M1 snnUlUR'UVs0sHnUSSSX�SS4_M sn5 O<U58VVs0sH'nU[(dMU[HnUU_M M) snnUlUR$R'U5 O U59Vs0sH
nU[U_M snUlU	(diUR((aXUR$R'U60Vs0sH1nU[*(dMU[*UR$U[_M3 sn5 UR-UR$[5Ulgs snfs snfs snnfs snfs snnfs snfs snf)NFr�r})r�rQrRrSrT�result_column_structrw�_merge_cursor_descriptionrGrNrPrC�setrErAr?�61setdefault�addrMr��_translate_colnamerIrjrU)r]�parent�cursor_descriptionr��result_columns�cols_are_ordered�textual_ordered�ad_hoc_textual�loose_column_name_matching�num_ctx_cols�rawr��by_key�index_by_key�dupesr^r��obj_elems                  r_�__init__�CursorResultMetaData.__init__gsM��62�.�.�� ���#'�� �16�6���t���'�'��,�,�

�� ���*��~�.�L��	
�N�
�-�
��
��
�!;��63�,�,��������&�	64��@C�65�?B�^�<�(�s�66���-1��)�67�'*�<�&)�N��}�-�~�=�&)�
�<�68�6�{�l�*�02�����&)�N� .�/?� @�B�&�z�2�8�b� ��-�X�6��(�2�2�3��<��C�!�I�I�c�N� �'*�+.� �*-��%�j�1��%3�:�$>���u�,�	-�H�n�,�%?��*-� ����
�
�$)��#(�C��d�B��C�d�D�A�A�#(���+.� �*-��%�j�1��%3�:�$>���n�,�%?��*-� ���
�L�L����'�69'*��&)�N��}�-�~�=�&)��D�L��� :� :��L�L���70+.�	�+.��%�o�6�	�N�?�3�T�\�\�&�}�5�6��+.�	�
�"�4�4�T�\�\�8�L����U71��<��D ���� ����sB�J9�-J>�K�K�-K�K	�0K�K�K�K�*"Kc	���U(a�U(a�U(d�U[U5:Xa�UV	s/sHo�SPM	 sn	UlSUl[U5V72Vs/sHGup�U73U74U[U[75U[URU[U[X*S5S4PMI snn76$U(dU(a)[U5U:XaSUlURXU5nO;U(aSUlURUUUU5nOSUlURX5nUV77V
VVVVVs/sH$un78n
nnnnnU79U
UUUURX�U5U4PM& snnnnnn
n80$s sn	fs snn81fs snnnnnn
n82f)a�83Merge a cursor.description with compiled result column information.84 85There are at least four separate strategies used here, selected86depending on the type of SQL construct used to start with.87 88The most common case is that of the compiled SQL expression construct,89which generated the column names present in the raw SQL string and90which has the identical number of columns as were reported by91cursor.description.  In this case, we assume a 1-1 positional mapping92between the entries in cursor.description and the compiled object.93This is also the most performant case as we disregard extracting /94decoding the column names present in cursor.description since we95already have the desired name we generated in the compiled SQL96construct.97 98The next common case is that of the completely raw string SQL,99such as passed to connection.execute().  In this case we have no100compiled construct to work with, so we extract and decode the101names from cursor.description and index those as the primary102result row target keys.103 104The remaining fairly common case is that of the textual SQL105that includes at least partial column information; this is when106we use a :class:`_expression.TextualSelect` construct.107This construct may have108unordered or ordered column information.  In the ordered case, we109merge the cursor.description and the compiled construct's information110positionally, and warn if there are additional description names111present, however we still decode the names in cursor.description112as we don't have a guarantee that the names in the columns match113on these.   In the unordered case, we match names in cursor.description114to that of the compiled construct based on name matching.115In both of these cases, the cursor.description names and the column116expression objects and names are indexed as result row target keys.117 118The final case is much less common, where we have a compiled119non-textual SQL expression construct, but the number of columns120in cursor.description doesn't match what's in the compiled121construct.  We make the guess here that there might be textual122column expressions in the compiled construct that themselves include123a comma in them causing them to split.  We do the same name-matching124as with textual non-ordered columns.125 126The name-matched system of merging is the same as that used by127SQLAlchemy for all cases up through the 0.9 series.   Positional128matching for compiled SQL expressions was introduced in 1.0 as a129major performance feature, and positional matching for textual130:class:`_expression.TextualSelect` objects in 1.1.131As name matching is no longer132a common case, it was acceptable to factor it into smaller generator-133oriented methods that are easier to understand, but incur slightly134more performance overhead.135 136rTrNF)rwrOrSr�r$r#r%�get_result_processorr&�_merge_textual_cols_by_position�_merge_cols_by_name�_merge_cols_by_none)r]r�r�r�r�r�r�r�r��elemr��137rmap_entry�raw_iterator�ridx�cursor_colname�mapped_type�coltype�obj�untranslateds                   r_r��.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�*�/��2��138��(A��
�(��3�'9�#:�l�#J�'+��$�#�C�C��� ���139(-��$�#�7�7��&�"�.�	 ��(-��$�#�7�7�� ��0"�)��("����"���� �#���"�"��0�0�#�W��!�140�&"�)�
��s>����`�s�E�AE�"+E!c#�J# �URnURnUR(aUROSnSn/Ul[U5HPupxUSn	USn141U(a142U"U	5up�U(aU"U	5n	URR
U	5 XyXj4v� MR g7f)z�Extract column names and data types from a cursor.description.143 144Applies unicode decoding, column translation, "normalization",145and case sensitivity rules to the names based on the dialect.146 147Nrr)�dialectr��requires_name_normalize�normalize_namerOr��append)r]r�r�r��translate_colnamer�r�r�r��colnamer�s           r_�_colnames_from_description�/CursorResultMetaData._colnames_from_description�s�����/�/��#�6�6��&-�&E�&E�G�"�"�4�	�����148�!�"4�5�H�C��!�f�G��!�f�G� �(9�'�(B�%���(��1���J�J���g�&���5�5�6�s�B!B#c#�# �[U5nU[U5:�a$[R"SU[U54-5 [5nUR	X5H{unnnn	Xd:aRX6n149U150[151nUnU152[n
USU;a[R"SUS-5eURUS5 O[Rn
SnSnXlX}X�U4v� M} g7f)NzVNumber of columns in textual SQL (%d) is smaller than number of columns requested (%d)rz8Duplicate column expression requested in textual SQL: %r)rwr�warnr�r�r$r&r�InvalidRequestErrorr�r �NULLTYPE)r]r�r�r�r��seenr�r�r�r��ctx_recr�r�r�s              r_r��4CursorResultMetaData._merge_textual_cols_by_position�s����>�*���#�0�1�1��I�I�@���%7�!8�9�:�
�153�u���
,�
,�W�
I�
154������!�(�-���j�)����%�g�.���q�6�T�>��1�1�-�/2�1�v�6�������Q�� �&�/�/�������W�7��M�M�!J�s�CCc#��# �URX45nURX5H'unnnn	XWn155U156SnU157SnU158Sn
UU
UUU	UU4v� M) g![a [RnSnSn
N0f=f7f)NrrrB)�_create_description_match_mapr��KeyErrorr r�)r]r�r�r�r��	match_mapr�r�r�r�r�r�r��result_columns_idxs              r_r��(CursorResultMetaData._merge_cols_by_name�s�����6�6��159�	��
,�
,�W�
I�
160�����	
0�#�,���a�j��%�a�j��%,�Q�Z�"��"�������
�J���
*�&�/�/����%)�"�
*�s'�+A5�A�A5�A2�/A5�1A2�2A5c	�@�0n[U5H�upEU[nXc;aX6upxp�XxU[-X�4X6'OU[U[U[U4X6'U(dMQU[H.nURUU[U[U[U45 M0 M� U$)z�when matching cursor.description to a set of names that are present161in a Compiled object, as is the case with TextualSelect, get all the162names we expect might match those in cursor.description.163)r�r%r$r#r&r�)�clsr�r��dr�r�r^�e_name�e_obj�e_type�e_ridx�r_keys            r_r��2CursorResultMetaData._create_description_match_maps���
�	164�$�N�3�J�D��'�(�C��x�16512��-��v���j�)9�!9�6�G����w�-��j�)9�4��=�$�O���)�)�"�*�-�E��L�L���g���Z�(8�$�w�-��N��.�%4�.�rbc#�# �/UlURX5H!unnnnUSU[RUSU4v� M# g7fr[)rOr�r r�)r]r�r�r�r�r�r�s       r_r��(CursorResultMetaData._merge_cols_by_none,s\���166��167��
,�
,�W�
I�
168���������!�!�����
�J�s�?Ac���U(auUR(a6[U[R5(a[R169"S5Ue[R170"S[R"U5-5Ueg)Nz9Row was unpickled; lookup by ColumnElement is unsupportedz.Could not locate column in row for column '%s')rTr�r�
ColumnElementr�NoSuchColumnErrorr�string_or_unprintable)r]r^�err�raiseerrs    r_�
_key_fallback�"CursorResultMetaData._key_fallbackEsr����?�?�z�#�x�7M�7M�'N�'N��/�/�)����171�/�/�H��4�4�S�9�:����172rbc�B�[R"SU[-5e)Nz<Ambiguous column name '%s' in result set column descriptions)rr�rC)r]r�s  r_� _raise_for_ambiguous_column_name�5CursorResultMetaData._raise_for_ambiguous_column_nameVs*���%�%�
-�/2�=�/A�
B�173�	174rbc���[U[5(aURUnURUnUSnUcUR
U5 U$![a!nURXU5nUbeSnAgSnAff=f�Nr)r��intrOrMr�r�r�)r]r^r�r��ke�xr�s       r_�_index_for_key�#CursorResultMetaData._index_for_key^s���175�c�3����*�*�S�/�C�	��,�,�s�#�C��A����=��1�1�#�6�����	��"�"�3�H�5�A��9��9���	�s�A�176A;�A6�6A;c���UVs/sHo RUSPM sn$s snf![a-n[RXRSU5 SnAgSnAff=fr�)rMr�rKr��args)r]rmr^rs    r_�_indexes_for_keys�&CursorResultMetaData._indexes_for_keysssY��	E�48�9�D�S�L�L��%�a�(�D�9�9��9���	E� �.�.�t�W�W�Q�Z��D�D��	E�s �)�$�)�)�177A �#A�A c#�j# �UHon[URR;aURUnURUnW[nUcURU5 [[U5v� Mq g![178a-n[RXRSU5 SnANfSnAff=f7fr�)
r�rh�__mro__rOrMr�rKr�rr?r�r�_NonAmbigCursorKeyMapRecType)r]rmr^r�rr�s      r_r��'CursorResultMetaData._metadata_for_keys|s�����C��c�m�m�+�+�+��j�j��o��
I��l�l�3�'��179��M�E��}��5�5�c�:��3�S�9�9����
I�$�2�2�4�����R�H�H��
I�s.�3B3�A9�4B3�9180B0�#B+�&B3�+B0�0B3c��URR5VVs0sHAup[U[[45(dM"UU[181U[/UU[SS4_MC snnURURS.$s snnf)N)rMrOrR)182rMrxr��strr�r?r@rErOrR)r]r^r�s   r_�__getstate__�!CursorResultMetaData.__getstate__�s���!%��� 2� 2� 4��!5�H�C��c�C��:�.�����M��+�,����(�)�����!5���Z�Z�#'�#;�#;�183�	184��s�!B�#Bc�~�[[US55Vs/sHnSPM snUlUSUlSUlURUR[5UlUSUlSUl	US(a,[SUS5Ul[UR6Ul
gS=UlUl
gs snf)NrOrMTrRz	List[int])�rangerwrNrMrPrjr?rUrOrTrrRrrQ)r]�state�_s   r_�__setstate__�!CursorResultMetaData.__setstate__�s���*/��E�'�N�0C�*D�E�*D�Q�D�*D�E����Y�'���,0��)�!�4�4�T�\�\�8�L����7�^��185�����&�'�'+��U�#8�9�(�D�$�!,�T�-E�-E� F�D��;?�?�D�$�t�'8��Fs�B:)	rUrMrPrOrNrSrRrQrTN)r^r�returnrW)rr)rkrWrlr9rmz
Sequence[str]rnr7rozOptional[_TupleGetterType]rprXrqrWrrrrrK)rrK)r�rKrrK)rm�Sequence[_KeyIndexType]rr)r�r4rr)r��CursorResult[Any]r�r.)r�r-r�r.r��Sequence[ResultColumnsEntry]r�r�r�rWr�rWr�rWr�rWrzList[_CursorKeyMapRecType])r�r-r�r.rz3Iterator[Tuple[int, str, Optional[str], DBAPIType]])r�r-r�r.r�rr�Iterator[_MergeColTuple])186r�r-r�r.r�rr�rWrr�F)r�rr�rWrzDDict[Union[str, object], Tuple[str, TupleAny, TypeEngine[Any], int]])r�r-r�r.rr)T)r^rr�zOptional[Exception]r�rWrzOptional[NoReturn])r�r6rr
)r^r5r�rWr�
Optional[int])rmrrz
Sequence[int])rmrrz&Iterator[_NonAmbigCursorKeyMapRecType])r�Dict[str, Any])rrr�None) �__name__�187__module__�__qualname__�__firstlineno__�__doc__�	__slots__�__annotations__rYr`rertrzr�r�r�r�r�r�r�r��classmethodr�r�rr�r�rrr�rr�__static_attributes__r�rbr_rKrK�s���,��I��� � �"E�E�����,�,�#'�L�.�'�#�188����$�	�189���
�0��0����&)��190��0191� 192�)�193�	�194�@195�@<196�|SM�!�SM�4�SM�jV�(�V�4�V�5�	V�197�V��
V��V��V�%)�V�198$�V�p!6�(�!6�4�!6�199=�	!6�F%N�(�%N�4�%N�5�	%N�200201"�%N�N$�(�$�4�$�5�	$�202%)�$�203"�
$�L�,1�%�4�%�%)�%�204N�	%��%�N�(��4��205"�	�.�HL�	��	�!4�	�@D�	�
�	�"206�!�207�	�208�48�� ��,0��	��*E�+�E�	�E�:�+�:�	/�:�(209�(
@rbrKc���\rSrSr%SrSrSrS\S'SSjrSSjr	SS	jr210SSS211jjrSSSjjrSSjr
SS
jrSrg)�ResultFetchStrategyi�zIDefine a fetching strategy for a result object.212 213 214.. versionadded:: 1.4215 216r�N�!Optional[_DBAPICursorDescription]�alternate_cursor_descriptionc��[5er[��NotImplementedError�r]�result�dbapi_cursors   r_�217soft_close�ResultFetchStrategy.soft_close��
��"�#�#rbc��[5er[r-r/s   r_�218hard_close�ResultFetchStrategy.hard_close�r4rbc��gr[r��r]r0r1�nums    r_�	yield_per�ResultFetchStrategy.yield_per�s��	rbc��[5er[r-�r]r0r1r6s    r_�fetchone�ResultFetchStrategy.fetchone��
��"�#�#rbc��[5er[r-�r]r0r1�sizes    r_�	fetchmany�ResultFetchStrategy.fetchmany�rArbc��[5er[r-r/s   r_�fetchall�ResultFetchStrategy.fetchall�s
��219"�#�#rbc��Uer[r��r]r0r1r�s    r_�handle_exception�$ResultFetchStrategy.handle_exception�s	���	rb�r0rr1�Optional[DBAPICursor]rr�r0rr1r1r:r�rrr�r0rr1r1r6rWrrr[�r0rr1r1rDrrr�r0rr1r1rr�r0rr1rOr��
BaseExceptionrr
)rr r!r"r#r$r+r%r2r6r;r?rErHrLr'r�rbr_r)r)�s+����I�FJ� �"C�J�$�'�$�7L�$�	
�$�220$�'�$�7L�$�	
�$�221�!��"���	�222223��!�	$�!�$�"�$��	$�224225
�$�#�	$�!�$�"�$��	$�226227
�$�$�!�$�"�$�228
�	$��!��,���	�229230�rbr)c��\rSrSrSrSrSSjrSSjrSS
SjjrSSSjjr	SS	jr231SSS232jjrSrg)�NoCursorFetchStrategyi�z�Cursor strategy for a result that has no open cursor.233 234There are two varieties of this strategy, one for DQL and one for235DML (and also DDL), each of which represent a result that had a cursor236but no longer has one.237 238r�c��gr[r�r/s   r_r2� NoCursorFetchStrategy.soft_close����239	
rbc��gr[r�r/s   r_r6� NoCursorFetchStrategy.hard_closerZrbc�&�URUS5$r[��_non_resultr>s    r_r?�NoCursorFetchStrategy.fetchones�������-�-rbNc�&�URU/5$r[r^rCs    r_rE�NoCursorFetchStrategy.fetchmanys�������+�+rbc�&�URU/5$r[r^r/s   r_rH�NoCursorFetchStrategy.fetchalls�������+�+rbc��[5er[r-�r]r0�defaultr�s    r_r_�!NoCursorFetchStrategy._non_result rArbrNrrQr[rRrS�r0rrgrr��Optional[BaseException]rr)
rr r!r"r#r$r2r6r?rErHr_r'r�rbr_rWrW�s����I�
�!�
�,�
�240�	
�
�!�
�,�
�241�	
�!�	.�!�.�"�.��	.�242243
�.�#�	,�!�,�"�,��	,�244245
�,�,�'�,�7B�,�	�,�(,�	$�!�$��$�%�	$�246247
�$�$rbrWc�:�\rSrSrSrSrSSSjjrSrg)�NoCursorDQLFetchStrategyi)a�Cursor strategy for a DQL result that has no open cursor.248 249This is a result set that can return rows, i.e. for a SELECT, or for an250INSERT, UPDATE, DELETE that includes RETURNING. However it is in the state251where the cursor is closed and no rows remain available.  The owning result252object may or may not be "hard closed", which determines if the fetch253methods send empty results or raise for closed result.254 255r�Nc�V�UR(a[R"S5UeU$)NzThis result object is closed.)�closedr�ResourceClosedErrorrfs    r_r_�$NoCursorDQLFetchStrategy._non_result6s+���=�=��)�)�/���
��Nrbr[ri�rr r!r"r#r$r_r'r�rbr_rlrl)sC����I�(,�	�!����%�	�256257
��rbrlc�:�\rSrSrSrSrSSSjjrSrg)�NoCursorDMLFetchStrategyiGz�Cursor strategy for a DML result that has no open cursor.258 259This is a result set that does not return rows, i.e. for an INSERT,260UPDATE, DELETE that does not include RETURNING.261 262r�Nc�t�URR(aeURRU5 gr[)�	_metadatarY�_we_dont_return_rowsrfs    r_r_�$NoCursorDMLFetchStrategy._non_resultQs-���#�#�0�0�0�0����-�-�c�2rbr[rirqr�rbr_rsrsGsC����I�(,�	3�!�3��3�%�	3�263264
�3�3rbrsc���\rSrSrSrSrSSjrSSjrS
SjrSSjr	SSSjjr265SSS266jjrSSjrSr
g	)�CursorFetchStrategyi_z�Call fetch methods from a DBAPI cursor.267 268Alternate versions of this class may instead buffer the rows from269cursors or not use cursors at all.270 271r�c��[Ulgr[��_NO_CURSOR_DQL�cursor_strategyr/s   r_r2�CursorFetchStrategy.soft_closei���"0��rbc��[Ulgr[r{r/s   r_r6�CursorFetchStrategy.hard_closenrrbc�T�URRUSSX!R5 gr[)�272connection�_handle_dbapi_exceptionr�rKs    r_rL�$CursorFetchStrategy.handle_exceptionss%��	���1�1���t�\�>�>�	273rbc�P�[USU0[R"5SS9Ulg)N�max_row_bufferr)�initial_buffer�
growth_factor)�BufferedRowCursorFetchStrategy�collections�dequer}r9s    r_r;�CursorFetchStrategy.yield_per}s,��"@��
�s�#�&�,�,�.��	"274��rbc��UR5nUcURUS9 U$![anURXU5 SnAgSnAff=f�N��hard)r?�_soft_closerUrL)r]r0r1r6�rowr�s      r_r?�CursorFetchStrategy.fetchone�sS��	;��'�'�)�C��{��"�"�275�"�3��J���	;��!�!�&��:�:��	;�s�#&�276A�A�ANc���UcUR5nOURU5nU(dUR5 U$![anURXU5 SnAgSnAff=fr[)rEr�rUrL)r]r0r1rD�lr�s      r_rE�CursorFetchStrategy.fetchmany�sa��277	;��|� �*�*�,�� �*�*�4�0����"�"�$��H���	;��!�!�&��:�:��	;�s�=A�278A&�279A!�!A&c��UR5nUR5 U$![anURXU5 SnAgSnAff=fr[)rHr�rUrL)r]r0r1�rowsr�s     r_rH�CursorFetchStrategy.fetchall�sI��280	;��(�(�*�D���� ��K���	;��!�!�&��:�:��	;�s�!$�281A282�A�A283rNrTrPrrQr[rRrS)rr r!r"r#r$r2r6rLr;r?rErHr'r�rbr_ryry_s����I�0�'�0�7L�0�	
�0�2840�'�0�7L�0�	
�0�285286�!�287�,�288��	289�290291�292�293�'�294�7B�295�IL�296�	
�297�!�	;�!�;�"�;��	;�298299
�;�$#�	;�!�;�"�;��	;�300301
�;�$302;�!�303;�"�304;�305
�	306;rbryc�^�\rSrSrSrSrSSSjjr\SSj5rSSjr	SSjr307SU4SjjrSU4S	jjrSSS308jjr
SSSjjrSSjrS
rU=r$)r�i�a�A cursor fetch strategy with row buffering behavior.309 310This strategy buffers the contents of a selection of rows311before ``fetchone()`` is called.  This is to allow the results of312``cursor.description`` to be available immediately, when313interfacing with a DB-API that requires rows to be consumed before314this information is available (currently psycopg2, when used with315server-side cursors).316 317The pre-fetching behavior fetches only one row initially, and then318grows its buffer size by a fixed amount with each successive need319for additional rows up the ``max_row_buffer`` size, which defaults320to 1000::321 322    with psycopg2_engine.connect() as conn:323 324        result = conn.execution_options(325            stream_results=True, max_row_buffer=50326        ).execute(text("select * from table"))327 328.. versionadded:: 1.4 ``max_row_buffer`` may now exceed 1000 rows.329 330.. seealso::331 332    :ref:`psycopg2_execution_options`333)�_max_row_buffer�334_rowbuffer�_bufsize�_growth_factorc�"�URSS5UlUbX@lO*[R"URS55UlX0lU(a&[URUR5UlgURUlg)Nr�i�r)	�getr�r�r�r�rEr��minr�)r]r1�execution_optionsr�r�s     r_r��'BufferedRowCursorFetchStrategy.__init__�sr�� 1�4�4�5E�t�L����%�,�O�)�/�/��0F�0F�q�0I�J�D�O�+����� 4� 4�d�6I�6I�J�D�M� �0�0�D�Mrbc�V�[URURR5$r[)r��cursorr�r�)r�r0s  r_�create�%BufferedRowCursorFetchStrategy.create�s%��.��M�M��N�N�,�,�335�	336rbc��URnUS:aUR5nOURU5nW(dg[337R"U5UlUR(a8X0R:a([URX0R-5Ulggg![anUR	XU5 SnAN�SnAff=f)z*this is currently used only by fetchone().rN)r�rHrErUrLr�r�r�r�r�r�)r]r0r1rD�new_rowsr�s      r_�_buffer_rows�+BufferedRowCursorFetchStrategy._buffer_rows�s���338�}�}��	;��a�x�'�0�0�2��'�1�1�$�7����%�+�+�H�5������4�*>�*>�#>���$�$�d�-@�-@�&@��D�M�$?���
�	;��!�!�&��:�:��	;�s�B$�B$�$339C340�.C�C341c�.�SUlU=UlUlgr�)r�r�r�r9s    r_r;�(BufferedRowCursorFetchStrategy.yield_pers�� ���/2�2���t�}rbc�X>�URR5 [TU]
X5 gr[�r��clear�superr2�r]r0r1rhs   �r_r2�)BufferedRowCursorFetchStrategy.soft_close�"���	
������
���6�0rbc�X>�URR5 [TU]
X5 gr[�r�r�r�r6r�s   �r_r6�)BufferedRowCursorFetchStrategy.hard_closer�rbc��UR(d3URX5 UR(dURUS9 gURR5$![anUR	XU5 SnAgSnAff=fr�)r�r�r�rUrL�popleft)r]r0r1r6r�s     r_r?�'BufferedRowCursorFetchStrategy.fetchonesy��������f�3��?�?�C��&�&�J�&�7�����&�&�(�(��%�C��)�)�&��B�B���C�s�A�342B�)B�Bc���UcURX5$URn[U5nSnX5:�a0URX5-3435nU(dSnOUR	U5 [[U[U555V	s/sHo�R5PM n344n	U(aUR5 U345$![346anUR
XU5 SnANuSnAff=fs sn	f)NFT)rHr�rwrE�extendrUrLrr�r�r�)r]r0r1rD�rb�lb�closer�r�r�ress           r_rE�(BufferedRowCursorFetchStrategy.fetchmany*s����<��=�=��6�6�
�_�_��
��W�����9�	
#�"�,�,�T�Y�7��� �E��I�I�c�N�%*�3�t�S��W�+=�%>�?�%>��z�z�|�%>��?����� ��347��!�
?��%�%�f�A�>�>��
?��@s�B7�C �7348C�C�Cc��[UR5[UR55-nURR5 UR	5 U$![349anUR
XU5 SnAgSnAff=fr[)r�r�rHr�r�rUrL)r]r0r1�retr�s     r_rH�'BufferedRowCursorFetchStrategy.fetchallGsl��	;��t���'�$�|�/D�/D�/F�*G�G�C��O�O�!�!�#���� ��J���	;��!�!�&��:�:��	;�s�AA�350B�'A>�>B)r�r�r�r�)rFN)351r1r1r�r0r�r�r�zOptional[Deque[Any]]rr)r0rrr�)r0rr1r1rrrPrNrrQr[rRrS)rr r!r"r#r$r�r&r�r�r;r2r6r?rErHr'�
__classcell__�rhs@r_r�r��so����6P�I��/3�1�!�1�7�1��	1�352-�1�353�
1�(�354�&�355�	'�356��357��'��7B��	
��,3�'�3�7B�3�IL�3�	
�3�1�'�1�7L�1�	
�1�1�'�1�7L�1�	
�1�!�	)�!�)�"�)��	)�358359
�)�(#�	�!��"���	�360361
��:	;�'�	;�7B�	;�	�	;�	;rbr�c��^�\rSrSrSrSrSSSjjrS
SjrSU4SjjrSU4Sjjr	SSSjjr362SSS	jjrSS363jrSr
U=r$)� FullyBufferedCursorFetchStrategyiSz�A cursor strategy that buffers rows fully upon creation.364 365Used for operations where a result is to be delivered366after the database conversation can not be continued,367such as MSSQL INSERT...OUTPUT after an autocommit.368 369)r�r+c��X lUb[R"U5UlgUce[R"UR	55Ulgr[)r+r�r�r�rH)r]r1�alternate_descriptionr�s    r_r��)FullyBufferedCursorFetchStrategy.__init__^sJ��-B�)��%�)�/�/��?�D�O��+�+�+�)�/�/��0E�0E�0G�H�D�Orbc��gr[r�r9s    r_r;�*FullyBufferedCursorFetchStrategy.yield_perks��	
rbc�X>�URR5 [TU]
X5 gr[r�r�s   �r_r2�+FullyBufferedCursorFetchStrategy.soft_closepr�rbc�X>�URR5 [TU]
X5 gr[r�r�s   �r_r6�+FullyBufferedCursorFetchStrategy.hard_closevr�rbc�x�UR(aURR5$URUS9 gr�)r�r�r�r>s    r_r?�)FullyBufferedCursorFetchStrategy.fetchone|s2���?�?��?�?�*�*�,�,����J��/�rbc���UcURX5$URn[[U[	U555Vs/sHoTR5PM nnU(dUR
5 U$s snfr[)rHr�rr�rwr�r�)r]r0r1rDr�rr�s       r_rE�*FullyBufferedCursorFetchStrategy.fetchmany�se���<��=�=��6�6�
�_�_��&+�C��c�"�g�,>�&?�@�&?��370�371��&?��@����� ����As�A5c�r�URn[R"5UlUR5 U$r[)r�r�r�r�)r]r0r1r�s    r_rH�)FullyBufferedCursorFetchStrategy.fetchall�s.���o�o��%�+�+�-��������372rb)NN)r1rOr�r*r�zOptional[Iterable[Any]])r0rr1r1r:r�rrrNrrQr[rRrS)rr r!r"r#r$r�r;r2r6r?rErHr'r�r�s@r_r�r�Ss ����?�I�373DH�26�	I�+�I� A�I�0�	I�
�'�
�7B�
�IL�
�	�
�3741�'�1�7L�1�	
�1�1�'�1�7L�1�	
�1�!�	375�!�376�"�377��	378�379380
�381� #�	
�!�
�"�
��	
�382383
�
��'��7B��	��rbr�c��\rSrSrSrSrS
SSjjrSSjrSSjrSSjr	\384SS	j5r\385SS386j5r\387SSj5r
\388SSj5rSrg)�_NoResultMetaDatai�r�FNc�0�[R"S5Ue)NzJThis result object does not return rows. It has been closed automatically.)rro)r]r�s  r_rv�&_NoResultMetaData._we_dont_return_rows�s!���%�%�
0�389��	rbc�$�UR5 gr[�rv)r]rmr�s   r_r� _NoResultMetaData._index_for_key�����!�!�#rbc�$�UR5 gr[r��r]rms  r_r��$_NoResultMetaData._metadata_for_keys�r�rbc�$�UR5 gr[r�r�s  r_r��_NoResultMetaData._reduce�r�rbc�$�UR5 gr[r��r]s r_rM�_NoResultMetaData._keymap�����!�!�#rbc�$�UR5 gr[r�r�s r_rU�_NoResultMetaData._key_to_index�r�rbc�$�UR5 gr[r�r�s r_rN�_NoResultMetaData._processors�r�rbc�$�UR5 gr[r�r�s r_rm�_NoResultMetaData.keys�r�rbr[)r�rjrr
)rmr5r�rWrr
)rmrrr
)rr
)rr r!r"r$rYrvrr�r��propertyrMrUrNrmr'r�rbr_r�r��s����I��L�.2��*��	��$�$�$��$��$��$��$��$��$��$��$rbr�c�`�[[5[/55nUR5 U$r[)rr��iterr�)�its r_�null_dml_resultr��s%��,�->�-@�$�r�(�K�B��N�N��
�Irbc�B^�\rSrSr%SrSrS\S'\rSr	S\S'Sr390S\S	'S391rS\S'S
\S'S\S'S\S'S1SjrS2Sjr
S3S4Sjjr\S5Sj5r\S6Sj5rS7SjrS7Sjr\S8Sj5rS9SjrS9SjrS:Sjr\S;Sj5rS<SjrS=S jrS=S!jrS<S"jrS<S#jr\R>S>S$j5r \S>S%j5r!\S<S&j5r"\S<S'j5r#S?S(jr$S3S@S)jjr%SAS*jr&SBSCS+jjr'SAS,jr(SDU4S-jjr)SES.jr*\+SFS/j5r,S0r-U=r.$)G�CursorResulti�a�A Result that is representing state from a DBAPI cursor.392 393.. versionchanged:: 1.4  The :class:`.CursorResult``394   class replaces the previous :class:`.ResultProxy` interface.395   This classes are based on the :class:`.Result` calling API396   which provides an updated usage model and calling facade for397   SQLAlchemy Core and SQLAlchemy ORM.398 399Returns database rows via the :class:`.Row` class, which provides400additional API features and behaviors on top of the raw data returned by401the DBAPI.   Through the use of filters such as the :meth:`.Result.scalars`402method, other kinds of objects may also be returned.403 404.. seealso::405 406    :ref:`tutorial_selecting_data` - introductory material for accessing407    :class:`_engine.CursorResult` and :class:`.Row` objects.408 409)r�r�r�r}�_echor�z.Union[CursorResultMetaData, _NoResultMetaData]ruFrW�_soft_closedrnTr-r�r3r�r)r}r,r�c�^	^410^^^
�XlURUlURUlX lURUlUR411R=(a URR5=UlnUb�URX5n[R"[UURUR5m412UR(a6[ R""[%UR*55mSU413U4SjjnUm
OT414m
U(a;URR415R&mSU4Sjjm	T	UlSU	U
4SjjnUnOT
nUR+SU5 gURS:XdeUR,Ulg)Nc� >�T"T"U55$r[r�)�raw_data�	_make_row�sentinel_filters ��r_�_sliced_row�*CursorResult.__init__.<locals>._sliced_rows���$�_�X�%>�?�?rbc�B>�T"S[R"U55 U$)NzRow %r)�sql_util�	_repr_row)r��logs �r_�_log_row�'CursorResult.__init__.<locals>._log_row&s�����(�"4�"4�S�"9�:��Jrbc� >�T"T"U55$r[r�)r�r�416sliced_rows ��r_�_make_row_2�*CursorResult.__init__.<locals>._make_row_2,s���#�J�s�O�4�4rb�_row_getterr)r�rrr)r�rrr)r�r�r�r}�root_connectionr�r��engine�_should_log_debug�_init_metadata�	functools�partialr�_effective_processorsrU�_num_sentinel_cols�operator�417itemgetter�slice�418_log_debug�_row_logging_fn�_set_memoized_attribute�_no_result_metadataru)r]r�r}r��echo�metadatar�r�make_rowrr�rr�rs         @@@@@r_r��CursorResult.__init__�sU�����������n�n���.��!�1�1����O�O�!�!�H�g�n�n�&F�&F�&H�	419��420�T��)�421�*�*�7�G�H�"�)�)����.�.��&�&�	�I��)�)�"*�"5�"5��7�5�5�5�6�#��@�@�)�422�&�423���l�l�-�-�8�8���(0��$�5�5�'��%���(�(���A��-�-��2�2�2�!�5�5�D�Nrbc�j�UR(a�URnUR(a
URnO"[X5nUR(aXClURRSS5(d^UR(aMURURRLa*URURLaURU5nX@l
O[X5=Ul
nUR(a,URR!S[#SU555 U$)N� _result_disable_adapt_to_contextFzCol %rc3�*# �UH	oSv� M g7f)rNr�)r�rs  r_r��.CursorResult._init_metadata.<locals>.<genexpr>hs���A�.@��!��.@�s�)r��_cached_metadatarKrSr�r�r��	cache_hitr��	CACHE_HITr�r�r�rur�r�r�tuple)r]r�r�r�rs     r_r�CursorResult._init_metadata8s�������'�'�H��(�(�#�4�4��/��I���+�+�08�-�"�-�-�1�1�6�����,�,��%�%����)B�)B�B��&�&�g�.G�.G�G�#�5�5�g�>��%�N�)=��)�
�D�N�X��:�:����)�)��%�A�.@�A�A�
��rbc��U(dUR(dU(aUR(agU(a-SUlURRXR5 O%URRXR5 UR(d6URnSUlURRU5 SUlgg)aSoft close this :class:`_engine.CursorResult`.424 425This releases all DBAPI cursor resources, but leaves the426CursorResult "open" from a semantic perspective, meaning the427fetchXXX() methods will continue to return empty results.428 429This method is called automatically when:430 431* all result rows are exhausted using the fetchXXX() methods.432* cursor.description is None.433 434This method is **not public**, but is documented in order to clarify435the "autoclose" process used.436 437.. seealso::438 439    :meth:`_engine.CursorResult.close`440 441 442NT)r�rnr}r6r�r2r��_safe_close_cursor)r]r�r�s   r_r��CursorResult._soft_closels���,��*�*��������D�K�� � �+�+�D�+�+�>�� � �+�+�D�+�+�>�� � ��[�[�F��D�K��O�O�.�.�v�6� $�D��	!rbc�T�URR(d[R"S5eURR(d[R"S5eURR443(a[R"S5eURR$)a�Return the value of444:attr:`_engine.CursorResult.inserted_primary_key`445as a row contained within a list; some dialects may support a446multiple row form as well.447 448.. note:: As indicated below, in current SQLAlchemy versions this449   accessor is only useful beyond what's already supplied by450   :attr:`_engine.CursorResult.inserted_primary_key` when using the451   :ref:`postgresql_psycopg2` dialect.   Future versions hope to452   generalize this feature to more dialects.453 454This accessor is added to support dialects that offer the feature455that is currently implemented by the :ref:`psycopg2_executemany_mode`456feature, currently **only the psycopg2 dialect**, which provides457for many rows to be INSERTed at once while still retaining the458behavior of being able to return server-generated primary key values.459 460* **When using the psycopg2 dialect, or other dialects that may support461  "fast executemany" style inserts in upcoming releases** : When462  invoking an INSERT statement while passing a list of rows as the463  second argument to :meth:`_engine.Connection.execute`, this accessor464  will then provide a list of rows, where each row contains the primary465  key value for each row that was INSERTed.466 467* **When using all other dialects / backends that don't yet support468  this feature**: This accessor is only useful for **single row INSERT469  statements**, and returns the same information as that of the470  :attr:`_engine.CursorResult.inserted_primary_key` within a471  single-element list. When an INSERT statement is executed in472  conjunction with a list of rows to be INSERTed, the list will contain473  one row per row inserted in the statement, however it will contain474  ``None`` for any server-generated values.475 476Future releases of SQLAlchemy will further generalize the477"fast execution helper" feature of psycopg2 to suit other dialects,478thus allowing this accessor to be of more general use.479 480.. versionadded:: 1.4481 482.. seealso::483 484    :attr:`_engine.CursorResult.inserted_primary_key`485 486�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 r_r/�&CursorResult.inserted_primary_key_rows�s���\�|�|�$�$��)�)�C��
����&�&��)�)�D��
��\�\�
0�
0��)�)���
�487�|�|�5�5�5rbc��URR(a[R"S5eURnU(aUS$g)a�Return the primary key for the row just inserted.488 489The return value is a :class:`_result.Row` object representing490a named tuple of primary key values in the order in which the491primary key columns are configured in the source492:class:`_schema.Table`.493 494.. versionchanged:: 1.4.8 - the495   :attr:`_engine.CursorResult.inserted_primary_key`496   value is now a named tuple via the :class:`_result.Row` class,497   rather than a plain tuple.498 499This accessor only applies to single row :func:`_expression.insert`500constructs which did not explicitly specify501:meth:`_expression.Insert.returning`.    Support for multirow inserts,502while not yet available for most backends, would be accessed using503the :attr:`_engine.CursorResult.inserted_primary_key_rows` accessor.504 505Note that primary key columns which specify a server_default clause, or506otherwise do not qualify as "autoincrement" columns (see the notes at507:class:`_schema.Column`), and were generated using the database-side508default, will appear in this list as ``None`` unless the backend509supports "returning" and the insert statement executed with the510"implicit returning" enabled.511 512Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed513statement is not a compiled expression construct514or is not an insert() construct.515 516zuThis statement was an executemany call; if primary key returning is supported, please use .inserted_primary_key_rows.rN)r��executemanyrr�r/)r]�ikps  r_�inserted_primary_key�!CursorResult.inserted_primary_key�sF��B�<�<�#�#��)�)�2��
��,�,����q�6�M�rbc�Z�URR(d[R"S5eURR(d[R"S5eURR517(aURR$URRS$)z�Return the collection of updated parameters from this518execution.519 520Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed521statement is not a compiled expression construct522or is not an update() construct.523 524r+z2Statement is not an update() expression construct.r)r�r�rr��isupdater2�compiled_parametersr�s r_�last_updated_params� CursorResult.last_updated_params�����|�|�$�$��)�)�C��
����&�&��)�)�D��
��\�\�
%�
%��<�<�3�3�3��<�<�3�3�A�6�6rbc�Z�URR(d[R"S5eURR(d[R"S5eURR525(aURR$URRS$)z�Return the collection of inserted parameters from this526execution.527 528Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed529statement is not a compiled expression construct530or is not an insert() construct.531 532r+r,r)r�r�rr�r-r2r8r�s r_�last_inserted_params�!CursorResult.last_inserted_paramsr;rbc�.�URR$)z�Return a list of rows each containing the values of default533columns that were fetched using534the :meth:`.ValuesBase.return_defaults` feature.535 536The return value is a list of :class:`.Row` objects.537 538.. versionadded:: 1.4539 540)r��returned_default_rowsr�s r_�returned_defaults_rows�#CursorResult.returned_defaults_rows1s���|�|�1�1�1rbc��UR5n[[UR55[UR555VVs/sHup4[	U5[	U5-PM nnnUR541R
UR5425Ul[SUS9UlUR5 U$s snnf)a+Return a new :class:`.CursorResult` that "horizontally splices"543together the rows of this :class:`.CursorResult` with that of another544:class:`.CursorResult`.545 546.. tip::  This method is for the benefit of the SQLAlchemy ORM and is547   not intended for general use.548 549"horizontally splices" means that for each row in the first and second550result sets, a new row that concatenates the two rows together is551produced, which then becomes the new row.  The incoming552:class:`.CursorResult` must have the identical number of rows.  It is553typically expected that the two result sets come from the same sort554order as well, as the result rows are spliced together based on their555position in the result.556 557The expected use case here is so that multiple INSERT..RETURNING558statements (which definitely need to be sorted) against different559tables can produce a single result that looks like a JOIN of those two560tables.561 562E.g.::563 564    r1 = connection.execute(565        users.insert().returning(566            users.c.user_name, users.c.user_id, sort_by_parameter_order=True567        ),568        user_values,569    )570 571    r2 = connection.execute(572        addresses.insert().returning(573            addresses.c.address_id,574            addresses.c.address,575            addresses.c.user_id,576            sort_by_parameter_order=True,577        ),578        address_values,579    )580 581    rows = r1.splice_horizontally(r2).all()582    assert rows == [583        ("john", 1, 1, "foo@bar.com", 1),584        ("jack", 2, 2, "bar@bat.com", 2),585    ]586 587.. versionadded:: 2.0588 589.. seealso::590 591    :meth:`.CursorResult.splice_vertically`592 593 594N�r�)595�	_generate�zipr��_raw_row_iteratorr%rur�r�r}�_reset_memoizations)r]r��clone�r1�r2�596total_rowss      r_�splice_horizontally� CursorResult.splice_horizontally@s���n��� ����T�+�+�-�.��U�,�,�.�/��597����
�"�I��b�	�!��	�598� �/�/�>�>�u���O��� @��%�!599���	�!�!�#����600s�#B?c���UR5n[UR55[UR55-n[SUS9UlUR5 U$)amReturn a new :class:`.CursorResult` that "vertically splices",601i.e. "extends", the rows of this :class:`.CursorResult` with that of602another :class:`.CursorResult`.603 604.. tip::  This method is for the benefit of the SQLAlchemy ORM and is605   not intended for general use.606 607"vertically splices" means the rows of the given result are appended to608the rows of this cursor result. The incoming :class:`.CursorResult`609must have rows that represent the identical list of columns in the610identical order as they are in this :class:`.CursorResult`.611 612.. versionadded:: 2.0613 614.. seealso::615 616    :meth:`.CursorResult.splice_horizontally`617 618NrD)rEr�rGr�r}rH)r]r�rIrLs    r_�splice_vertically�CursorResult.splice_vertically�sd��(��� ���$�0�0�2�3�d��#�#�%�7619�620�621�!A��%�!622���	�!�!�#��rbc��UR(a/URRRS[	U55 [[UR5R5Ul[SUS9Ul623UR5 U$)z�rewind this result back to the given rowset.624 625this is used internally for the case where an :class:`.Insert`626construct combines the use of627:meth:`.Insert.return_defaults` along with the628"supplemental columns" feature.629 630zCursorResult rewound %d row(s)NrD)r�r�r�rrwrrKrurzr�r}rH�r]r�s  r_�_rewind�CursorResult._rewind�sz���:�:��L�L�#�#�.�.�0�#�d�)�
�� �$�.�.�631�632�633�634�	
�� @�� � 635���	
� � �"��rbc��URR(a[R"S5eURRnU(aUS$g)a@Return the values of default columns that were fetched using636the :meth:`.ValuesBase.return_defaults` feature.637 638The value is an instance of :class:`.Row`, or ``None``639if :meth:`.ValuesBase.return_defaults` was not used or if the640backend does not support RETURNING.641 642.. seealso::643 644    :meth:`.ValuesBase.return_defaults`645 646zlThis statement was an executemany call; if return defaults is supported, please use .returned_defaults_rows.rN)r�r2rr�r@rSs  r_�returned_defaults�CursorResult.returned_defaults�sJ���<�<�#�#��)�)�D��
�647�|�|�1�1�����7�N�rbc�6�URR5$)z�Return ``lastrow_has_defaults()`` from the underlying648:class:`.ExecutionContext`.649 650See :class:`.ExecutionContext` for details.651 652)r��lastrow_has_defaultsr�s r_rZ�!CursorResult.lastrow_has_defaults�s���|�|�0�0�2�2rbc�(�URR(d[R"S5eURR(d1URR653(d[R"S5eURR$)aReturn ``postfetch_cols()`` from the underlying654:class:`.ExecutionContext`.655 656See :class:`.ExecutionContext` for details.657 658Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed659statement is not a compiled expression construct660or is not an insert() or update() construct.661 662r+�>Statement is not an insert() or update() expression construct.)r�r�rr�r-r7�postfetch_colsr�s r_r^�CursorResult.postfetch_cols�sl���|�|�$�$��)�)�C��
����&�&�t�|�|�/D�/D��)�)�(��
��|�|�*�*�*rbc�(�URR(d[R"S5eURR(d1URR663(d[R"S5eURR$)aReturn ``prefetch_cols()`` from the underlying664:class:`.ExecutionContext`.665 666See :class:`.ExecutionContext` for details.667 668Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed669statement is not a compiled expression construct670or is not an insert() or update() construct.671 672r+r])r�r�rr�r-r7�
prefetch_colsr�s r_ra�CursorResult.prefetch_colssl���|�|�$�$��)�)�C��
����&�&�t�|�|�/D�/D��)�)�(��
��|�|�)�)�)rbc�.�URR$)zpReturn ``supports_sane_rowcount`` from the dialect.673 674See :attr:`_engine.CursorResult.rowcount` for background.675 676)r��supports_sane_rowcountr�s r_rd�#CursorResult.supports_sane_rowcounts���|�|�2�2�2rbc�.�URR$)zvReturn ``supports_sane_multi_rowcount`` from the dialect.677 678See :attr:`_engine.CursorResult.rowcount` for background.679 680)r��supports_sane_multi_rowcountr�s r_rg�)CursorResult.supports_sane_multi_rowcount%s���|�|�8�8�8rbc��URR$![a,nURR	XR681U5 eSnAff=f)a0
Return the 'rowcount' for this result.682 683The primary purpose of 'rowcount' is to report the number of rows684matched by the WHERE criterion of an UPDATE or DELETE statement685executed once (i.e. for a single parameter set), which may then be686compared to the number of rows expected to be updated or deleted as a687means of asserting data integrity.688 689This attribute is transferred from the ``cursor.rowcount`` attribute690of the DBAPI before the cursor is closed, to support DBAPIs that691don't make this value available after cursor close.   Some DBAPIs may692offer meaningful values for other kinds of statements, such as INSERT693and SELECT statements as well.  In order to retrieve ``cursor.rowcount``694for these statements, set the695:paramref:`.Connection.execution_options.preserve_rowcount`696execution option to True, which will cause the ``cursor.rowcount``697value to be unconditionally memoized before any results are returned698or the cursor is closed, regardless of statement type.699 700For cases where the DBAPI does not support rowcount for a particular701kind of statement and/or execution, the returned value will be ``-1``,702which is delivered directly from the DBAPI and is part of :pep:`249`.703All DBAPIs should support rowcount for single-parameter-set704UPDATE and DELETE statements, however.705 706.. note::707 708   Notes regarding :attr:`_engine.CursorResult.rowcount`:709 710 711   * This attribute returns the number of rows *matched*,712     which is not necessarily the same as the number of rows713     that were actually *modified*. For example, an UPDATE statement714     may have no net change on a given row if the SET values715     given are the same as those present in the row already.716     Such a row would be matched but not modified.717     On backends that feature both styles, such as MySQL,718     rowcount is configured to return the match719     count in all cases.720 721   * :attr:`_engine.CursorResult.rowcount` in the default case is722     *only* useful in conjunction with an UPDATE or DELETE statement,723     and only with a single set of parameters. For other kinds of724     statements, SQLAlchemy will not attempt to pre-memoize the value725     unless the726     :paramref:`.Connection.execution_options.preserve_rowcount`727     execution option is used.  Note that contrary to :pep:`249`, many728     DBAPIs do not support rowcount values for statements that are not729     UPDATE or DELETE, particularly when rows are being returned which730     are not fully pre-buffered.   DBAPIs that dont support rowcount731     for a particular kind of statement should return the value ``-1``732     for such statements.733 734   * :attr:`_engine.CursorResult.rowcount` may not be meaningful735     when executing a single statement with multiple parameter sets736     (i.e. an :term:`executemany`). Most DBAPIs do not sum "rowcount"737     values across multiple parameter sets and will return ``-1``738     when accessed.739 740   * SQLAlchemy's :ref:`engine_insertmanyvalues` feature does support741     a correct population of :attr:`_engine.CursorResult.rowcount`742     when the :paramref:`.Connection.execution_options.preserve_rowcount`743     execution option is set to True.744 745   * Statements that use RETURNING may not support rowcount, returning746     a ``-1`` value instead.747 748.. seealso::749 750    :ref:`tutorial_update_delete_rowcount` - in the :ref:`unified_tutorial`751 752    :paramref:`.Connection.execution_options.preserve_rowcount`753 754N)r��rowcountrUr}rLr��r]r�s  r_rj�CursorResult.rowcount.sE��X	��<�<�(�(�(���	�� � �1�1�$���Q�G���	�s��755A�'A	�	Ac��URR5$![a0nURR	XR756U5 SnAgSnAff=f)a�Return the 'lastrowid' accessor on the DBAPI cursor.757 758This is a DBAPI specific method and is only functional759for those backends which support it, for statements760where it is appropriate.  It's behavior is not761consistent across backends.762 763Usage of this method is normally unnecessary when764using insert() expression constructs; the765:attr:`~CursorResult.inserted_primary_key` attribute provides a766tuple of primary key values for a newly inserted row,767regardless of database backend.768 769N)r��
get_lastrowidrUr}rLr�rks  r_�	lastrowid�CursorResult.lastrowid�sJ�� 	H��<�<�-�-�/�/���	H�� � �1�1�$���Q�G�G��	H�s��770A�&A�Ac�.�URR$)a%True if this :class:`_engine.CursorResult` returns zero or more771rows.772 773I.e. if it is legal to call the methods774:meth:`_engine.CursorResult.fetchone`,775:meth:`_engine.CursorResult.fetchmany`776:meth:`_engine.CursorResult.fetchall`.777 778Overall, the value of :attr:`_engine.CursorResult.returns_rows` should779always be synonymous with whether or not the DBAPI cursor had a780``.description`` attribute, indicating the presence of result columns,781noting that a cursor that returns zero rows still has a782``.description`` if a row-returning statement was emitted.783 784This attribute should be True for all results that are against785SELECT statements, as well as for DML statements INSERT/UPDATE/DELETE786that use RETURNING.   For INSERT/UPDATE/DELETE statements that were787not using RETURNING, the value will usually be False, however788there are some dialect-specific exceptions to this, such as when789using the MSSQL / pyodbc dialect a SELECT is emitted inline in790order to retrieve an inserted primary key value.791 792.. seealso::793 794    :meth:`.Result.close`795 796    :attr:`.Result.closed`797 798)rurYr�s r_rY�CursorResult.returns_rows�s��>�~�~�*�*�*rbc�.�URR$)a4True if this :class:`_engine.CursorResult` is the result799of a executing an expression language compiled800:func:`_expression.insert` construct.801 802When True, this implies that the803:attr:`inserted_primary_key` attribute is accessible,804assuming the statement did not include805a user defined "returning" construct.806 807)r�r-r�s r_�	is_insert�CursorResult.is_insert�s���|�|�$�$�$rbc#�p# �URRnU"XR5nUcgUv� M7fr[�r}r?r�)r]r?r�s   r_�_fetchiter_impl�CursorResult._fetchiter_impl�s9����'�'�0�0����4���-�C��{���I�	�s�46c�N�URRXRU5$r[rw)r]r6s  r_�_fetchone_impl�CursorResult._fetchone_impl�s���#�#�,�,�T�;�;�808�K�Krbc�L�URRXR5$r[)r}rHr�r�s r_�_fetchall_impl�CursorResult._fetchall_impl�s���#�#�,�,�T�;�;�?�?rbc�N�URRXRU5$r[)r}rEr�)r]rDs  r_�_fetchmany_impl�CursorResult._fetchmany_impl�s���#�#�-�-�d�K�K��F�Frbc�"�UR5$r[)rxr�s r_rG�CursorResult._raw_row_iterator�s���#�#�%�%rbc�>�[TU]"U6nURR(a[	SU4U-55UlU$)Nc3�N# �UHn[SU5Rv� M g7f)rN)rrj)r�r0s  r_r��%CursorResult.merge.<locals>.<genexpr>�s%���)�.�F��(�&�1�:�:�.�s�#%)r��merger��
_has_rowcount�sumrj)r]�others�
merged_resultrhs   �r_r��CursorResult.merge�sG�����
�v�.�
��<�<�%�%�%(�)�#�g��.�)�&�M�"��rbc�"�URSS9 g)a�Close this :class:`_engine.CursorResult`.809 810This closes out the underlying DBAPI cursor corresponding to the811statement execution, if one is still present.  Note that the DBAPI812cursor is automatically released when the :class:`_engine.CursorResult`813exhausts all available rows.  :meth:`_engine.CursorResult.close` is814generally an optional method except in the case when discarding a815:class:`_engine.CursorResult` that still has additional rows pending816for fetch.817 818After this method is called, it is no longer valid to call upon819the fetch methods, which will raise a :class:`.ResourceClosedError`820on subsequent use.821 822.. seealso::823 824    :ref:`connections_toplevel`825 826Tr�N)r�r�s r_r��CursorResult.close�s��(	
���d��#rbc�^�XlURRXRU5 U$r[)�827_yield_perr}r;r�)r]r:s  r_r;�CursorResult.yield_per�s&�������&�&�t�[�[�#�>��rb)r�rurr�r�rnr�r�r�r}r�)r�r-r}r)r�r*)r�r-r�r.rrKr)r�rWrr)rzList[Optional[Any]])rz
Optional[Any])rzMUnion[List[_MutableCoreSingleExecuteParams], _MutableCoreSingleExecuteParams])rzOptional[Sequence[Row[Any]]])r�rrr+)r�rrr+)rzOptional[Row[Any]])rrW)rzOptional[Sequence[Column[Any]]])rr�)rz
Iterator[Any])r6rWrr)rrr[)rDrrr)r�zResult[Any]rzMergedResult[Any])rr)r:r�rr+)/rr r!r"r#r$r%�_NO_RESULT_METADATArr�rn�828_is_cursorr�rr�r�r/r4r9r=rArMrPrTrWrZr^rardrgr�memoized_propertyrjrorYrtrxr{r~r�rGr�r�r!r;r'r�r�s@r_r�r��s�����(�I�>�=�-���L�$���F�D���J�
$�$�
��(�(���=6�(�=6�-�=6�>�	=6�~2�(�2�4�2�829�	2�h#%�J�;6��;6�z�+��+�Z7�830�7�47�831�7�4�2�	%�2��2�G�R�@�@����43�+�.*�.3�9�832���O��O�b�H��H�(�+��+�@�%��%��L�@�G�&��$�,���rbr�)rzIteratorResult[Any])kr#�833__future__rr�rr�typingrrrrrr	r834rrr
rrrrrrr0rrrrrrr�r�rr�sqlrr r�sql.baser!�sql.compilerr"r#r$r%r&�sql.type_apir'r(�util.typingr)r*r+�baser,rgr-�835interfacesr.r/r0r1r2r3r4r5r6r7r8r9r:�836sql.schemar;r<r=�TupleAnyr?r%r@rArCrErGrIr�r
�_CursorKeyMapRecTyperVr837�_MergeColTuplerKr)rWrlr|rs�_NO_CURSOR_DMLry�_DEFAULT_FETCHr�r�r�r�r�r��ResultProxyr�rbr_�<module>r�s����#����
�������������� ���"� ��"�(�������"�"�-�"�%�+�"�%���!��838��� �0�3�;�7�'�%�#�,�%�&�#� �'�(�#�3�
�T������c��?�� ��839���*+��&�*�/� !�840��!��$%�
� �$��'(��#�'��#$���#�3�%&��"�&�&���S�M������
(�)��S�M�
����J�(<�<�=�� %�����I����
(�)��
	� �����S�M���s�O���X���S�M�
���S@�>�S@�l;�;�|4$�/�4$�n�4��6*�+��3�4�3�**�+��R;�-�R;�j%�&��Y;�%8�Y;�xJ�':�J�Z$$��$$�N(�)���l�6�"�:�l�^�rb
codekingpro/portable-devtools · Team Ai