
    -h                       S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  S	S
K
Jr  S	SK
Jr  S	SKJr  S	SKJr  S	SKJr  S	SKJr  S	SKJr  S	SKJr  S	SKJr  S	SKJr  \R0                  " S5      rSrSrS	rSrSrSrSr  " S S\5      r! " S S\!5      r" " S S\#5      r$ " S S\$5      r% " S  S!\%5      r&\&" 5       r' " S" S#\%5      r(\(" 5       r) " S$ S%\$5      r*\*" 5       r+ " S& S'\*5      r, " S( S)\*5      r- " S* S+\5      r. " S, S-\.5      r/\." 5       r0\/" 5       r1 " S. S/\#5      r2 " S0 S1\2\5      r3 " S2 S3\35      r4\4r5 " S4 S5\55      r6 " S6 S7\55      r7 " S8 S9\	5      r8 " S: S;\55      r9g)<zjDefine cursor-specific result set constructs including
:class:`.BaseCursorResult`, :class:`.CursorResult`.    N   )Result)ResultMetaData)SimpleResultMetaData)tuplegetter)	LegacyRow   )exc)util)
expression)sqltypes)_generative)RM_NAME)
RM_OBJECTS)RM_RENDERED_NAME)RM_TYPE	unpickled            c                       \ rS rSrSrSrSrS rS rS r	S r
S	 rS
 rS rS rS r\  SS j5       rS rSS jrS rSS jrS rS rS rS rSrg)CursorResultMetaData-   z"Result metadata for DBAPI cursors.)_keymapcase_sensitive_processors_keys_keymap_by_result_column_idx_tuplefilter_translated_indexes_safe_for_cacheTc                     XR                   ;   $ N)r   selfkeys     mC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\sqlalchemy/engine/cursor.py_has_keyCursorResultMetaData._has_key?   s    ll""    c                     [        U R                  U R                   Vs/ s H  oR                  U   [           PM     snS9$ s  snf )N)extra)r   r   r   
MD_OBJECTSr%   s     r(   _for_freeze CursorResultMetaData._for_freezeB   s;    #JJ<@JJGJS<<$Z0JG
 	
Gs   A
c           	      2   [        U R                  U5      5      nU Vs/ s H  o3[           PM     nnU Vs/ s H  o3[           PM     nnU R                  (       a  U Vs/ s H  o`R                  U   PM     nn[        U6 nU R                  R                  U R                  5      nU R                  Ul        U R                  Ul	        XXl
        Xxl        XHl        [        U R                  U5      5       V	Vs/ s H  u  pU	4USS  -   PM     n
n	nU
 Vs0 s H  o3[           U_M     snUl        UR                  R                  U
 VVs0 s H  nU[           =(       d    S  H  nX_M     M!     snn5        U$ s  snf s  snf s  snf s  snn	f s  snf s  snnf )Nr    )list_metadata_for_keysMD_INDEXMD_LOOKUP_KEYr!   r   	__class____new__r   r   r   r    	enumerater   updater.   )r&   keysrecsrecindexesnew_keysidxtupnew_metadataindexnew_recsnew_reces                r(   _reduceCursorResultMetaData._reduceH   s   D++D12,01DSx=D1267$3&$7##@GH//4GH7#~~--dnn=&*&9&9##'#3#3 %$'!+2( ((?(?(EF
F
 Hs12wF 	 
 DLL8CM 2C 78L
 	##  ('G ,22A 
2 '	
 A 27 I
  Ms"   E9E> F8FF	&F
c                    UR                   R                  (       d  U $ UR                   R                  nUR                  nX#L a  U $ U R                  R                  U R                  5      n[        U R                  5      Ul        U R                  n[        UR                  5       H  u  pg XV   nXR                  U'   M     U R                  Ul        U R                  Ul        U R                  (       a   eSUl        SUl        U R                   Ul        U R                  Ul        U R"                  Ul        U$ ! [         a     M  f = f)a3  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)compiled_result_columns	statementinvoked_statementr7   r8   dictr   r   r9   _all_selected_columnsKeyErrorr   r   r    r!   r   r"   )	r&   contextcompiled_statementrM   mdkeymap_by_positionr@   newr=   s	            r(   _adapt_to_context&CursorResultMetaData._adapt_to_contextm   s'    //K$--77#552K ^^##DNN3$,,'
!>>!"3"I"IJHC&(- #&

3 K !//))$$$$!%::*.*K*K'!11	   s   ,D::
EEc           
         UR                   nUR                  nS U l        S U l        UR                  U l        SU l        UR                  (       a  UR                  u  nnnnn	[        U5      n
OS=n=n=n
=n=pU R                  UUUU
UUUU	5      n0 U l	        U Vs/ s H  o[           PM     snU l        UR                  (       a   U Vs0 s H  nU[           U_M     snU l        [        U Vs/ s H  nU[            U4PM     sn5      nU
(       Ga  [        U5      U
:w  Ga,  0 n[#        5       nU H  nU[$           4U[&           =(       d    S-    Hu  nU R                  (       d/  [)        U[*        R,                  5      (       a  UR/                  5       nU[0           nUR3                  UU5      U:w  d  Md  UR5                  U5        Mw     M     U R                  R7                  U VVs/ s H0  nU[&           (       d  M  U[&             H  nUU;  d  M  UU4PM     M2     snn5        UR7                  U Vs0 s H
  nUS S SU4_M     sn5        OQU R                  R7                  U VVs/ s H(  nU[&           (       d  M  U[&             H  nUU4PM	     M*     snn5        U R                  R7                  U5        U
(       dl  UR8                  (       aZ  U R                  R7                  U Vs/ s H2  nU[:           (       d  M  U[:           U R                  U[               4PM4     sn5        g g g s  snf s  snf s  snf s  snnf s  snf s  snnf s  snf )NFr2   )rQ   dialectr    r!   r   r"   result_column_structlen_merge_cursor_descriptionr   MD_PROCESSORr   rJ   MD_RESULT_MAP_INDEXr   rN   r6   setMD_RENDERED_NAMEr.   
isinstancer   string_typeslowerr5   
setdefaultaddr:   _translate_colnameMD_UNTRANSLATED)r&   parentcursor_descriptionrQ   rY   result_columnscols_are_orderedtextual_orderedad_hoc_textualloose_column_name_matchingnum_ctx_colsrawmetadata_entryby_keyindex_by_keydupesr'   r@   obj_elems                      r(   __init__CursorResultMetaData.__init__   s   ..// #' %44$'' ,, *~.L @EEN E E E
 E + ,,&	
 
 @C
?B^<(s
  '*1&)N 23^C&)1D-  '*&)N  .?&)
 6{l*  "&)N ./? @B&z28b   $22z!2!28 8 #&))+C,X6 (223<C!IIcN  '*  ## /2.1N)*5 3 )7z(BH#50	 3>2 )C 3.1 UKUcsT4S$99UKL
 ## /2.1N)*5 3 )7z(BH ">2 )C 3.1 	F#  : :LL +.
 +.%o6&7^M%BC +.	 !;|o

1Z LsB   L0L50L:)L?
?L?
L?
7M*M

 M

-M#Mc	                 B   UR                   R                  n	U(       a  U(       a  U(       d  U[        U5      :X  a  U V
s/ s H  oS   PM	     sn
U l        SU l        [        U5       VVs/ s He  u  pUUU[           U	(       d  U[           R                  5       OU[           U[           UR                  U[           U[           X+   S   5      S4PMg     snn$ U(       d  U(       a)  [        U5      U:X  a  SU l        U R                  XU5      nO;U(       a  SU l        U R                  UUUU5      nOSU l        U R                  X5      nU VVVVVVVs/ s H%  u  nnnnnnnUUUUUUR                  UUU5      U4PM'     snnnnnnn$ s  sn
f s  snnf s  snnnnnnnf )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 te 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.

r   Tr   NF)rY   r   r[   r   r"   r9   r   r   rc   r   get_result_processorr   _merge_textual_cols_by_position_merge_cols_by_name_merge_cols_by_none)r&   rQ   ri   rj   ro   rk   rl   rm   rn   r   elemr@   
rmap_entryraw_iteratorridxcursor_colnamemapped_typecoltypeobjuntranslateds                       r(   r\   .CursorResultMetaData._merge_cursor_description)  s   D !77  #$6 77.<=ndq'n=DJ $(D " (1'@!  (AOC z*) w'--/#G,/000"7+"#34*/2
  (A! . 3'9#:l#J'+$#CC  
 (-$#77&".	  (-$#77 0 ") ( "" # ""00#^W !
& ") u >f s   F*A,F,Fc              #     #    UR                   nUR                  nUR                  nUR                  (       a  UR                  OSnUR
                  (       a  UR                  OSnSn/ U l        [        U5       Hv  u  pU
S   nU
S   nU(       a  U" U5      nU(       a
  U" U5      u  pU(       a  U" U5      nU R                  R                  U5        U(       d  UR                  5       nXX4v   Mx     g7f)zExtract 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.

Nr   r   )rY   r   rf   description_encoding_description_decoderrequires_name_normalizenormalize_namer   r9   appendrc   )r&   rQ   ri   rY   r   translate_colnamedescription_decoderr   r   r@   r=   colnamer   s                r(   _colnames_from_description/CursorResultMetaData._colnames_from_description  s      // //#66 ++ (( 	 '.&E&EG""4 	 
!"45HC!fG!fG"-g6 (9'(B%(1JJg&!!--/55# 6s   C2C4c              #     #    U(       a  [        U5      OS nU[        U5      :  a$  [        R                  " SU[        U5      4-  5        [        5       nU R	                  X5       H{  u  nnnn	Xd:  aR  X6   n
U
[
           nUnU
[           nUS   U;   a  [        R                  " SUS   -  5      eUR                  US   5        O[        R                  nS nS nXlX}XU4v   M}     g 7f)NzVNumber of columns in textual SQL (%d) is smaller than number of columns requested (%d)r   z8Duplicate column expression requested in textual SQL: %r)r[   r   warnr_   r   r   r   r
   InvalidRequestErrorre   r   NULLTYPE)r&   rQ   ri   rj   ro   seenr@   r   r   r   ctx_recr   r   r   s                 r(   rz   4CursorResultMetaData._merge_textual_cols_by_position  s     /=s>*$#011II@%7!89:
 u ,,WI
!(-j)%g.q6T>11-/21v6  Q &//W7MM! Js   C#C%c              #      #    UR                   nUR                  nU R                  X6U5      nU R                  X5       H'  u  nn	n
n Xy   nUS   nUS   nUS   nUUU	UUUU
4v   M)     g ! [         a    [
        R                  nS nS n N0f = f7f)Nr   r	   r   )rY   r   _create_description_match_mapr   rP   r   r   )r&   rQ   ri   rj   rn   rY   r   	match_mapr@   r   r   r   r   r   r   result_columns_idxs                   r(   r{   (CursorResultMetaData._merge_cols_by_name  s      // //66,F
	 ,,WI
	0#, aj%aj%,QZ""  J  *&//%)"*s*   ABA*B*BB
BBc           	      n   0 n[        U5       H  u  pVU[           nU(       d  UR                  5       nXt;   a  XG   u  ppXU[           -   X4XG'   OU[           U[           U[
           U4XG'   U(       d  Mh  U[            H.  nUR                  UU[           U[           U[
           U45        M0     M     U$ )zwhen 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.
)r9   r   rc   r   r   r   rd   )clsrj   r   rn   dr   r}   r'   e_namee_obje_typee_ridxr_keys                r(   r   2CursorResultMetaData._create_description_match_map7  s     #N3JD'(C!iikx
 12-vj)9!96Gw-j)94=$O)) "*-ELLgZ(8$w-N .+ 46 r+   c              #   x   #    U R                  X5       H!  u  nnnnUS U[        R                  US U4v   M#     g 7fr$   )r   r   r   )r&   rQ   ri   r@   r   r   r   s          r(   r|   (CursorResultMetaData._merge_cols_by_nonea  sS      ,,WI
 !!  Js   8:c                     U(       aA  [         R                  " [        R                  " S[         R                  " U5      -  5      US9  g g )N.Could not locate column in row for column '%s'replace_context)r   raise_r
   NoSuchColumnErrorstring_or_unprintable)r&   r'   errraiseerrs       r(   _key_fallback"CursorResultMetaData._key_fallbackr  s?    KK%%D0056 !$ r+   c                 B    [         R                  " SU[           -  5      e)Nz<Ambiguous column name '%s' in result set column descriptions)r
   r   r6   )r&   r=   s     r(    _raise_for_ambiguous_column_name5CursorResultMetaData._raise_for_ambiguous_column_name~  s(    %%-/2=/AB
 	
r+   c                    [        U[        5      (       a  U R                  U   n U R                  U   nUS   nUc  U R                  U5        U$ ! [         a$  nU R                  XU5      nUc   S nAg  S nANDS nAff = fNr   )ra   intr   r   rP   r   r   )r&   r'   r   r=   kerC   s         r(   _index_for_key#CursorResultMetaData._index_for_key  s     c3**S/C	,,s#C A=11#6  	$$Sh7C{ 	s   A 
A>A99A>c                      U Vs/ s H  o R                   U   S   PM     sn$ s  snf ! [         a-  n[        R                  XR                  S   U5         S nAg S nAff = fr   )r   rP   r   r   args)r&   r;   r'   r   s       r(   _indexes_for_keys&CursorResultMetaData._indexes_for_keys  sY    	E489DSLL%a(D999 	E ..tWWQZDD	Es    ) $) ) 
A #AA c              #   F  #    U H]  n[         UR                  R                  ;   a  U R                  U   n U R                  U   nWS   nUc  U R                  U5        Uv   M_     g ! [
         a-  n[        R                  XR                  S   U5         S nANTS nAff = f7fr   )
r   r7   __mro__r   r   rP   r   r   r   r   )r&   r;   r'   r=   r   rC   s         r(   r4   'CursorResultMetaData._metadata_for_keys  s     Ccmm+++jjoIll3'
 FE}55c:I   I$224RHHIs.   3B!A'"B!'
B1#BB!BB!c           	      X   U R                   R                  5        VVs0 s HO  u  p[        U[        R                  [        R
                  -   5      (       d  M7  X[           U[           [        U4_MQ     snnU R                  U R                  U R                  U R                  S.$ s  snnf )N)r   r   r   r!   r    )r   itemsra   r   rb   	int_typesr5   r^   
_UNPICKLEDr   r   r!   r    )r&   r'   r=   s      r(   __getstate__!CursorResultMetaData.__getstate__  s     !% 2 2 4 4HCc4#4#4t~~#EF P(mS)<%=z3OO 4
 ZZ"11#'#;#; --

 
	
s   6B&B&c                    [        [        US   5      5       Vs/ s H  nS PM     snU l        US   U l        U R                  R	                  5        Vs0 s H  o3[
           U_M     snU l        US   U l        US   U l        US   (       a"  US   U l	        [        U R                  6 U l        g S =U l	        U l        g s  snf s  snf )Nr   r   r   r!   )ranger[   r   r   valuesr^   r   r   r   r!   r   r    )r&   state_r=   s       r(   __setstate__!CursorResultMetaData.__setstate__  s    */E'N0C*DE*DQD*DEY' 6:\\5H5H5J-
5Jc#$c)5J-
) 7^
#$45&'',-B'CD$ +T-E-E FD;??D$t'8 F-
s   B>C)r   r   r   r   r"   r!   r    r   N)TFT)__name__
__module____qualname____firstlineno____doc__	__slots__returns_rowsr)   r/   rG   rV   rv   r\   r   rz   r{   classmethodr   r|   r   r   r   r   r4   r   r   __static_attributes__r2   r+   r(   r   r   -   s    ,I L#
#J,\L\Yv(6T!NF$L  #(	' 'R"

&E$
@r+   r   c                   4    \ rS rSrSrS rSS jrS rS rSr	g)	LegacyCursorResultMetaDatai  r2   c                 |    UnX0R                   ;   a  [        R                  " S5        gU R                  US S5      S L$ )NzUsing the 'in' operator to test for string or column keys, or integer indexes, in a :class:`.Row` object is deprecated and will be removed in a future release. Use the `Row._fields` or `Row._mapping` attribute, i.e. 'key in row._fields'TF)r   r   warn_deprecated_20r   )r&   valuerowr'   s       r(   	_contains$LegacyCursorResultMetaData._contains  sC    ,,##' %%c47tCCr+   c                    U R                   nS n[        U[        R                  5      (       a4  UR	                  U R
                  (       a  UOUR                  5       5      nGO[        U[        R                  5      (       Ga  UR                  (       av  U R
                  (       a  UR                  OUR                  R                  5       U;   a;  UU R
                  (       a  UR                  OUR                  R                  5          nO[        US5      (       au  U R
                  (       a  UR                  OUR                  R                  5       U;   a:  UU R
                  (       a  UR                  OUR                  R                  5          nUb=  U[           S [        4;  a*  U[            H  nUR                  U5      (       d  M    O   S nUb;  U[           [        L a  [        R                  " SSS9  O[        R                  " SSS9  UcJ  U(       aB  [        R                   " ["        R$                  " S[        R&                  " U5      -  5      US9  U$ g XTU'   U$ )NnamezRetrieving row values using Column objects from a row that was unpickled is deprecated; adequate state cannot be pickled for this to be efficient.   This usage will raise KeyError in a future release.z1.4)versionzRetrieving row values using Column objects with only matching names as keys is deprecated, and will raise KeyError in a future release; only Column objects that are explicitly part of the statement object should be used.r   r   )r   ra   r   rb   getr   rc   r   ColumnElement	_tq_labelhasattrr   r.   r   _compare_name_for_resultwarn_deprecatedr   r
   r   r   )r&   r'   r   r   map_resultr   s          r(   r   (LegacyCursorResultMetaData._key_fallback  s   ||c4,,--XXT%8%8cciikJFZ5566 ** MM,,. ** MM,,. V$$!%!4!4SXX#((..:J  $ 3 3CHH9I !fZ&8A ' "*-C33C88 . "F!*%3((N !& ((1
 !& >))H44S9: %(  Ir+   c                 .    [         R                  " SSS9  g )NzUsing non-integer/slice indices on Row is deprecated and will be removed in version 2.0; please use row._mapping[<key>], or the mappings() accessor on the Result object.r   )
stacklevelr   r   r%   s     r(   _warn_for_nonint+LegacyCursorResultMetaData._warn_for_nonint.  s    < 		
r+   c                 L    XR                   ;   a  gU R                  US S5      S L$ )NTF)r   r   r%   s     r(   r)   #LegacyCursorResultMetaData._has_key6  s)    ,,%%c47tCCr+   Nr   )
r   r   r   r   r   r   r   r   r)   r   r2   r+   r(   r   r     s    IDKZ
Dr+   r   c                   R    \ rS rSrSrSrSrS rS rS r	SS jr
SS	 jrS
 rS rSrg)ResultFetchStrategyi=  zIDefine a fetching strategy for a result object.


.. versionadded:: 1.4

r2   Nc                     [        5       er$   NotImplementedErrorr&   r   dbapi_cursors      r(   
soft_closeResultFetchStrategy.soft_closeI      !##r+   c                     [        5       er$   r   r   s      r(   
hard_closeResultFetchStrategy.hard_closeL  r   r+   c                     g r$   r2   r&   r   r   nums       r(   	yield_perResultFetchStrategy.yield_perO  s    r+   c                     [        5       er$   r   r&   r   r   r  s       r(   fetchoneResultFetchStrategy.fetchoneR  r   r+   c                     [        5       er$   r   r&   r   r   sizes       r(   	fetchmanyResultFetchStrategy.fetchmanyU  r   r+   c                     [        5       er$   r   )r&   r   s     r(   fetchallResultFetchStrategy.fetchallX  r   r+   c                     Uer$   r2   r&   r   r   r   s       r(   handle_exception$ResultFetchStrategy.handle_exception[  s    	r+   Fr$   )r   r   r   r   r   r   alternate_cursor_descriptionr   r  r  r
  r  r  r  r   r2   r+   r(   r   r   =  s7     I#' $$$$$r+   r   c                   L    \ rS rSrSrSrS rS rSS jrSS jr	S	 r
SS
 jrSrg)NoCursorFetchStrategyi_  zCursor 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.

r2   c                     g r$   r2   r   s      r(   r    NoCursorFetchStrategy.soft_closej      r+   c                     g r$   r2   r   s      r(   r   NoCursorFetchStrategy.hard_closem  r  r+   c                 &    U R                  US 5      $ r$   _non_resultr	  s       r(   r
  NoCursorFetchStrategy.fetchonep  s    --r+   Nc                 &    U R                  U/ 5      $ r$   r"  r  s       r(   r  NoCursorFetchStrategy.fetchmanys      ++r+   c                 &    U R                  U/ 5      $ r$   r"  r   s      r(   r  NoCursorFetchStrategy.fetchallv  r'  r+   c                     [        5       er$   r   r&   r   defaultr   s       r(   r#  !NoCursorFetchStrategy._non_resulty  r   r+   r  r$   )r   r   r   r   r   r   r   r  r
  r  r  r#  r   r2   r+   r(   r  r  _  s,     I.,,$r+   r  c                   &    \ rS rSrSrSrSS jrSrg)NoCursorDQLFetchStrategyi}  a  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.

r2   Nc                 |    UR                   (       a*  [        R                  " [        R                  " S5      US9  g U$ )NzThis result object is closed.r   )closedr   r   r
   ResourceClosedErrorr+  s       r(   r#  $NoCursorDQLFetchStrategy._non_result  s.    ==KK''(GH #
 Nr+   r$   r   r   r   r   r   r   r#  r   r2   r+   r(   r/  r/  }  s     Ir+   r/  c                   &    \ rS rSrSrSrSS jrSrg)NoCursorDMLFetchStrategyi  zCursor 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.

r2   Nc                 t    UR                   R                  (       a   eUR                   R                  U5        g r$   )	_metadatar   _we_dont_return_rowsr+  s       r(   r#  $NoCursorDMLFetchStrategy._non_result  s+    ##0000--c2r+   r$   r4  r2   r+   r(   r6  r6    s     I3r+   r6  c                   N    \ rS rSrSrSrS rS rS rS r	SS jr
SS
 jrS rSrg	)CursorFetchStrategyi  zCall fetch methods from a DBAPI cursor.

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

r2   c                     [         Ul        g r$   _NO_CURSOR_DQLcursor_strategyr   s      r(   r   CursorFetchStrategy.soft_close  
    !/r+   c                     [         Ul        g r$   r>  r   s      r(   r  CursorFetchStrategy.hard_close  rB  r+   c                 T    UR                   R                  US S X!R                  5        g r$   )
connection_handle_dbapi_exceptionrQ   r  s       r(   r  $CursorFetchStrategy.handle_exception  s#    11t\>>	
r+   c                 P    [        USU0[        R                  " 5       SS9Ul        g )Nmax_row_bufferr   )initial_buffergrowth_factor)BufferedRowCursorFetchStrategycollectionsdequer@  r  s       r(   r  CursorFetchStrategy.yield_per  s)    !?s#&,,.	"
r+   c                      UR                  5       nUc  UR                  US9  U$ ! [         a  nU R                  XU5         S nAg S nAff = fNhard)r
  _soft_closeBaseExceptionr  )r&   r   r   r  r   rF   s         r(   r
  CursorFetchStrategy.fetchone  sS    	;'')C{""
"3J 	;!!&::	;s   #& 
AAANc                      Uc  UR                  5       nOUR                  U5      nU(       d  UR                  5         U$ ! [         a  nU R                  XU5         S nAg S nAff = fr$   )r  rU  rV  r  )r&   r   r   r  lrF   s         r(   r  CursorFetchStrategy.fetchmany  sa    
	;| **, **40""$H 	;!!&::	;s   =A   
A&
A!!A&c                      UR                  5       nUR                  5         U$ ! [         a  nU R                  XU5         S nAg S nAff = fr$   )r  rU  rV  r  )r&   r   r   rowsrF   s        r(   r  CursorFetchStrategy.fetchall  sI    	;((*D K 	;!!&::	;s   !$ 
A
AA
r  r$   )r   r   r   r   r   r   r   r  r  r  r
  r  r  r   r2   r+   r(   r<  r<    s1     I00


;;;r+   r<  c                      ^  \ rS rSrSrSr  SS jr\S 5       rS r	S r
U 4S jrU 4S	 jrSS
 jrSS jrS rSrU =r$ )rM  i  a  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                 "   UR                  SS5      U l        Ub  X@l        O*[        R                  " UR                  S5      5      U l        X0l        U(       a&  [        U R                  U R                  5      U l        g U R                  U l        g )NrJ  i  r   )	r   r_  r`  rN  rO  r  rb  minra  )r&   r   execution_optionsrL  rK  s        r(   rv   'BufferedRowCursorFetchStrategy.__init__  sr      1445EtL%,O)//0F0Fq0IJDO+ 4 4d6I6IJDM 00DMr+   c                 V    [        UR                  UR                  R                  5      $ r$   )rM  cursorrQ   re  )r   r   s     r(   create%BufferedRowCursorFetchStrategy.create  s#    -MMNN,,
 	
r+   c                    U R                   n US:  a  UR                  5       nOUR                  U5      n W(       d  g[
        R                  " U5      U l        U R                  (       a8  X0R                  :  a(  [        U R                  X0R                  -  5      U l         ggg! [         a  nU R	                  XU5         SnANSnAff = f)z*this is currently used only by fetchone().r   N)ra  r  r  rV  r  rN  rO  r`  rb  r_  rd  )r&   r   r   r  new_rowsrF   s         r(   _buffer_rows+BufferedRowCursorFetchStrategy._buffer_rows"  s     }}	;ax'002'11$7 %++H54*>*>#>$$d-@-@&@DM $?  	;!!&::	;s   B$ B$ $
C
.CC
c                 .    SU l         U=U l        U l        g r   )rb  r_  ra  r  s       r(   r  (BufferedRowCursorFetchStrategy.yield_per6  s    /22t}r+   c                 `   > U R                   R                  5         [        [        U ]  X5        g r$   )r`  clearsuperrM  r   r&   r   r   r7   s      r(   r   )BufferedRowCursorFetchStrategy.soft_close:  &    ,d>	
r+   c                 `   > U R                   R                  5         [        [        U ]  X5        g r$   )r`  rr  rs  rM  r  rt  s      r(   r  )BufferedRowCursorFetchStrategy.hard_close@  rv  r+   c                    U R                   (       d3  U R                  X5        U R                   (       d   UR                  US9  g U R                   R                  5       $ ! [         a  nU R	                  XU5         S nAg S nAff = frR  )r`  rm  rU  rV  r  popleft)r&   r   r   r  rF   s        r(   r
  'BufferedRowCursorFetchStrategy.fetchoneF  sw    f3??C&&J&7 &&(( % C))&BBCs   A 
B)B  Bc                    Uc  U R                  X5      $ [        U R                  5      n[        U5      nX5:  a>   UR	                  X5-
  5      nU(       d  UR                  5         OUR                  U5         USU n[        R                  " XCS  5      U l        U$ ! [         a  nU R                  XU5         S nANES nAff = fr   )r  r3   r`  r[   r  rU  extendrV  r  rN  rO  )r&   r   r   r  buflbrU   rF   s           r(   r  (BufferedRowCursorFetchStrategy.fetchmanyQ  s    <==664??#X9$",,TY7 &&(JJsOQt%++CJ7 ! ?%%fA>>?s   B 
C&B==Cc                     [        U R                  5      [        UR                  5       5      -   nU R                  R                  5         UR	                  5         U$ ! [
         a  nU R                  XU5         S nAg S nAff = fr$   )r3   r`  r  rr  rU  rV  r  )r&   r   r   retrF   s        r(   r  'BufferedRowCursorFetchStrategy.fetchallf  sl    	;t'$|/D/D/F*GGCOO!!# J 	;!!&::	;s   AA 
B'A>>B)ra  rb  r_  r`  )r   Nr  r$   )r   r   r   r   r   r   rv   r   ri  rm  r  r   r  r
  r  r  r   __classcell__r7   s   @r(   rM  rM    sY    6 PI 1( 
 
(3

	)*; ;r+   rM  c                   h   ^  \ rS rSrSrSr SS jrS rU 4S jrU 4S jr	SS jr
SS	 jrS
 rSrU =r$ ) FullyBufferedCursorFetchStrategyip  zA 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`  r  c                     X l         Ub  [        R                  " U5      U l        g [        R                  " UR	                  5       5      U l        g r$   )r  rN  rO  r`  r  )r&   r   alternate_descriptionrK  s       r(   rv   )FullyBufferedCursorFetchStrategy.__init__{  s>     -B)%)//?DO)//0E0E0GHDOr+   c                     g r$   r2   r  s       r(   r  *FullyBufferedCursorFetchStrategy.yield_per  r  r+   c                 `   > U R                   R                  5         [        [        U ]  X5        g r$   )r`  rr  rs  r  r   rt  s      r(   r   +FullyBufferedCursorFetchStrategy.soft_close  &    .@	
r+   c                 `   > U R                   R                  5         [        [        U ]  X5        g r$   )r`  rr  rs  r  r  rt  s      r(   r  +FullyBufferedCursorFetchStrategy.hard_close  r  r+   c                 x    U R                   (       a  U R                   R                  5       $ UR                  US9  g rR  )r`  rz  rU  r	  s       r(   r
  )FullyBufferedCursorFetchStrategy.fetchone  s0    ????**,,J/r+   c                     Uc  U R                  X5      $ [        U R                  5      nUSU n[        R                  " XCS  5      U l        U(       d  UR                  5         U$ r   )r  r3   r`  rN  rO  rU  )r&   r   r   r  r~  r\  s         r(   r  *FullyBufferedCursorFetchStrategy.fetchmany  sY    <==664??#1T{%++CJ7 r+   c                 r    U R                   n[        R                  " 5       U l         UR                  5         U$ r$   )r`  rN  rO  rU  )r&   r   r   r  s       r(   r  )FullyBufferedCursorFetchStrategy.fetchall  s,    oo%++-
r+   )NNr  r$   )r   r   r   r   r   r   rv   r  r   r  r
  r  r  r   r  r  s   @r(   r  r  p  s?     ?I HLI

	 r+   r  c                   X    \ rS rSrSrSrSS jrS rS rS r	\
S	 5       r\
S
 5       rSrg)_NoResultMetaDatai  r2   FNc                 V    [         R                  " [        R                  " S5      US9  g )NzJThis result object does not return rows. It has been closed automatically.r   )r   r   r
   r2  )r&   r   s     r(   r9  &_NoResultMetaData._we_dont_return_rows  s&    ##4  	
r+   c                 $    U R                  5         g r$   r9  )r&   r;   r   s      r(   r    _NoResultMetaData._index_for_key      !!#r+   c                 $    U R                  5         g r$   r  r%   s     r(   r4   $_NoResultMetaData._metadata_for_keys  r  r+   c                 $    U R                  5         g r$   r  )r&   r;   s     r(   rG   _NoResultMetaData._reduce  r  r+   c                 $    U R                  5         g r$   r  r&   s    r(   r   _NoResultMetaData._keymap      !!#r+   c                 $    U R                  5         g r$   r  r  s    r(   r;   _NoResultMetaData.keys  r  r+   r$   )r   r   r   r   r   r   r9  r   r4   rG   propertyr   r;   r   r2   r+   r(   r  r    sH    IL
$$$ $ $ $ $r+   r  c                   $    \ rS rSr\S 5       rSrg)_LegacyNoResultMetaDatai  c                 2    [         R                  " S5        / $ )NzCalling the .keys() method on a result set that does not return rows is deprecated and will raise ResourceClosedError in SQLAlchemy 2.0.r   r  s    r(   r;   _LegacyNoResultMetaData.keys  s    	

 	r+   r2   N)r   r   r   r   r  r;   r   r2   r+   r(   r  r    s     r+   r  c                       \ rS rSrSrSrSrSrSrS r	S r
SS jr\S 5       r\S	 5       rS
 rS r\S 5       r\S 5       rS rS rS rS rS r\R2                  S 5       r\S 5       r\S 5       r\S 5       rSrg)BaseCursorResulti  z'Base class for database result objects.NFc                   ^^^ Xl         UR                  U l        UR                  U l        X l        UR                  U l        U R
                  R                  =(       a    UR                  R                  5       =U l        nUb  U(       a.  U R                   R
                  R                  mU4S jmTU l
        OS mU R                  X5      nUR                  nUR                  nU R                  nUR                  n	[         R"                  " XXvU	5      mT(       a  UU4S jn
OTn
U R%                  SU
5        g U R&                  U l        g )Nc                 B   > T" S[         R                  " U 5      5        U $ )NzRow %r)sql_util	_repr_row)r   logs    r(   log_row*BaseCursorResult.__init__.<locals>.log_row  s    ("4"4S"9:Jr+   c                 (   > T" U 5      nT" U5        U$ r$   r2   )r   made_row	_make_rowr  s     r(   make_row+BaseCursorResult.__init__.<locals>.make_row  s    (~HH%#Or+   _row_getter)rQ   rY   rh  r@  root_connectionrF  _echoengine_should_log_debug
_log_debug_row_logging_fn_init_metadatar   r   _process_row_default_key_style	functoolspartial_set_memoized_attribute_no_result_metadatar8  )r&   rQ   r@  ri   echometadatakeymap
processorsprocess_row	key_styler  r  r  r  s              @@@r(   rv   BaseCursorResult.__init__  s   nn.!11OO!!Hgnn&F&F&H	

T )
 ll--88 (/$**7GH%%F!--J++K#66I!))z9I $ %((A "55DNr+   c                    UR                   (       Ga  UR                   R                  (       a!  U R                  R                   R                  nO2U R                  X5      nUR                  (       a  X1R                   l        UR                   nU(       a  UR
                  (       an  UR                  UR                  R                  L aK  UR                  R                  SS5      (       d*  UR                  UR                  La  UR                  U5      nX0l        OU R                  X5      =U l        nU R                  (       a,  UR                   R#                  S[%        S U 5       5      5        U$ )N _result_disable_adapt_to_contextFzCol %rc              3   *   #    U  H	  oS    v   M     g7f)r   Nr2   ).0xs     r(   	<genexpr>2BaseCursorResult._init_metadata.<locals>.<genexpr>@  s     A.@!.@s   )rJ   _cached_metadatarQ   _cursor_metadatar"   rK   	cache_hitrY   	CACHE_HITre  r   rL   rM   rV   r8  r  rF  r  tuple)r&   rQ   ri   r  rJ   s        r(   r  BaseCursorResult._init_metadata  s$   00<<00AA00J++8@$$5  ''H,,%%)B)BB11556  &&g.G.GG#55g>%N )-(=(=) DNX ::))%A.@AA r+   c                    U(       d  U R                   (       d  U(       a  U R                  (       a  gU(       a-  SU l        U R                  R                  X R                  5        O%U R                  R                  X R                  5        U R                   (       d6  U R                  nSU l        U R                  R                  U5        SU l         gg)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.

.. versionadded:: 1.0.0

.. seealso::

    :meth:`_engine.CursorResult.close`


NT)_soft_closedr1  r@  r  rh  r   rF  _safe_close_cursor)r&   rT  rh  s      r(   rU  BaseCursorResult._soft_closeD  s    . **DK  ++D++>  ++D++>  [[FDKOO..v6 $D	 !r+   c                 T   U R                   R                  (       d  [        R                  " S5      eU R                   R                  (       d  [        R                  " S5      eU R                   R
                  (       a  [        R                  " S5      eU R                   R                  $ )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.)rQ   rJ   r
   r   isinsert_is_explicit_returninginserted_primary_key_rowsr  s    r(   r  *BaseCursorResult.inserted_primary_key_rowsj  s    \ ||$$))F  &&))G  \\00)) 
 ||555r+   c                     U R                   R                  (       a  [        R                  " S5      eU R                  nU(       a  US   $ g)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.r   N)rQ   executemanyr
   r   r  )r&   ikps     r(   inserted_primary_key%BaseCursorResult.inserted_primary_key  sF    B <<##))2  ,,q6Mr+   c                 Z   U R                   R                  (       d  [        R                  " S5      eU R                   R                  (       d  [        R                  " S5      eU R                   R
                  (       a  U R                   R                  $ U R                   R                  S   $ )zReturn 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   )rQ   rJ   r
   r   isupdater  compiled_parametersr  s    r(   last_updated_params$BaseCursorResult.last_updated_params       ||$$))F  &&))G  \\%%<<333<<33A66r+   c                 Z   U R                   R                  (       d  [        R                  " S5      eU R                   R                  (       d  [        R                  " S5      eU R                   R
                  (       a  U R                   R                  $ U R                   R                  S   $ )zReturn 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   )rQ   rJ   r
   r   r  r  r  r  s    r(   last_inserted_params%BaseCursorResult.last_inserted_params  r  r+   c                 .    U R                   R                  $ )zReturn 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

)rQ   returned_default_rowsr  s    r(   returned_defaults_rows'BaseCursorResult.returned_defaults_rows  s     ||111r+   c                     U R                   R                  (       a  [        R                  " S5      eU R                   R                  nU(       a  US   $ g)aY  Return 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.

.. versionadded:: 0.9.0

.. seealso::

    :meth:`.ValuesBase.return_defaults`

zlThis statement was an executemany call; if return defaults is supported, please use .returned_defaults_rows.r   N)rQ   r  r
   r   r  )r&   r\  s     r(   returned_defaults"BaseCursorResult.returned_defaults  sJ    " <<##))D 
 ||117Nr+   c                 6    U R                   R                  5       $ )zReturn ``lastrow_has_defaults()`` from the underlying
:class:`.ExecutionContext`.

See :class:`.ExecutionContext` for details.

)rQ   lastrow_has_defaultsr  s    r(   r   %BaseCursorResult.lastrow_has_defaults,  s     ||0022r+   c                 (   U R                   R                  (       d  [        R                  " S5      eU R                   R                  (       d1  U R                   R
                  (       d  [        R                  " S5      eU R                   R                  $ )a  Return ``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.)rQ   rJ   r
   r   r  r  postfetch_colsr  s    r(   r  BaseCursorResult.postfetch_cols6  sl     ||$$))F  &&t||/D/D))(  ||***r+   c                 (   U R                   R                  (       d  [        R                  " S5      eU R                   R                  (       d1  U R                   R
                  (       d  [        R                  " S5      eU R                   R                  $ )a  Return ``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  )rQ   rJ   r
   r   r  r  prefetch_colsr  s    r(   r  BaseCursorResult.prefetch_colsM  sl     ||$$))F  &&t||/D/D))(  ||)))r+   c                 .    U R                   R                  $ )zpReturn ``supports_sane_rowcount`` from the dialect.

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

)rY   supports_sane_rowcountr  s    r(   r
  'BaseCursorResult.supports_sane_rowcountd  s     ||222r+   c                 .    U R                   R                  $ )zvReturn ``supports_sane_multi_rowcount`` from the dialect.

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

)rY   supports_sane_multi_rowcountr  s    r(   r  -BaseCursorResult.supports_sane_multi_rowcountm  s     ||888r+   c                      U R                   R                  $ ! [         a0  nU R                  R	                  X R
                  U5         SnAgSnAff = f)av  Return the 'rowcount' for this result.

The 'rowcount' reports the number of rows *matched*
by the WHERE criterion of an UPDATE or DELETE statement.

.. 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* - an UPDATE statement, for example,
     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 by default to return the match
     count in all cases.

   * :attr:`_engine.CursorResult.rowcount`
     is *only* useful in conjunction
     with an UPDATE or DELETE statement.  Contrary to what the Python
     DBAPI says, it does *not* return the
     number of rows available from the results of a SELECT statement
     as DBAPIs cannot support this functionality when rows are
     unbuffered.

   * :attr:`_engine.CursorResult.rowcount`
     may not be fully implemented by
     all dialects.  In particular, most DBAPIs do not support an
     aggregate rowcount result from an executemany call.
     The :meth:`_engine.CursorResult.supports_sane_rowcount` and
     :meth:`_engine.CursorResult.supports_sane_multi_rowcount` methods
     will report from the dialect if each usage is known to be
     supported.

   * Statements that use RETURNING may not return a correct
     rowcount.

.. seealso::

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

N)rQ   rowcountrV  r@  r  rh  r&   rF   s     r(   r  BaseCursorResult.rowcountv  sH    `	H<<((( 	H  11$QGG	Hs    
A&AAc                      U R                   R                  5       $ ! [         a0  nU R                  R	                  X R
                  U5         SnAgSnAff = f)a  Return 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)rQ   get_lastrowidrV  r@  r  rh  r  s     r(   	lastrowidBaseCursorResult.lastrowid  sJ     	H<<--// 	H  11$QGG	Hs    
A&AAc                 .    U R                   R                  $ )a  True 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.


)r8  r   r  s    r(   r   BaseCursorResult.returns_rows  s    4 ~~***r+   c                 .    U R                   R                  $ )a4  True 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.

)rQ   r  r  s    r(   	is_insertBaseCursorResult.is_insert  s     ||$$$r+   )
r  r8  r  r  r1  rF  rQ   rh  r@  rY   r  )r   r   r   r   r   out_parametersr8  r  r1  rv   r  rU  r  r  r  r  r  r  r  r   r  r  r
  r  r   memoized_propertyr  r  r   r  r   r2   r+   r(   r  r    s    1NILF/6b.`$%L ;6 ;6z + +Z7,7, 
2 
2  83+.*.39 
2H 2Hh H H( + +6 % %r+   r  c                   x   ^  \ rS rSrSr\r\r\	r
SrS rSS jrS rSS jrS rU 4S	 jrS
 r\S 5       rSrU =r$ )CursorResulti  a  A Result that is representing state from a DBAPI cursor.

.. versionchanged:: 1.4  The :class:`.CursorResult` and
   :class:`.LegacyCursorResult`
   classes replace the previous :class:`.ResultProxy` interface.
   These 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.

Within the scope of the 1.x series of SQLAlchemy, Core SQL results in
version 1.4 return an instance of :class:`._engine.LegacyCursorResult`
which takes the place of the ``CursorResult`` class used for the 1.3 series
and previously.  This object returns rows as :class:`.LegacyRow` objects,
which maintains Python mapping (i.e. dictionary) like behaviors upon the
object itself.  Going forward, the :attr:`.Row._mapping` attribute should
be used for dictionary behaviors.

.. seealso::

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

Tc              #   p   #    U R                   R                  n U" X R                  5      nUc  g Uv   M  7fr$   r@  r
  rh  )r&   r
  r   s      r(   _fetchiter_implCursorResult._fetchiter_impl  s9     ''004-C{I	 s   46c                 N    U R                   R                  X R                  U5      $ r$   r!  )r&   r  s     r(   _fetchone_implCursorResult._fetchone_impl  s    ##,,T;;
KKr+   c                 L    U R                   R                  X R                  5      $ r$   )r@  r  rh  r  s    r(   _fetchall_implCursorResult._fetchall_impl  s    ##,,T;;??r+   c                 N    U R                   R                  X R                  U5      $ r$   )r@  r  rh  )r&   r  s     r(   _fetchmany_implCursorResult._fetchmany_impl  s    ##--dKKFFr+   c                 "    U R                  5       $ r$   )r"  r  s    r(   _raw_row_iteratorCursorResult._raw_row_iterator   s    ##%%r+   c                    > [         [        U ]
  " U6 nU R                  R                  (       + nU(       a  [        S U 4U-    5       5      Ul        U$ )Nc              3   8   #    U  H  oR                   v   M     g 7fr$   )r  )r  r   s     r(   r  %CursorResult.merge.<locals>.<genexpr>'  s      ).>F.>s   )rs  r  merger8  r   sumr  )r&   othersmerged_resultsetup_rowcountsr7   s       r(   r3  CursorResult.merge#  sR    lD7@"nn999%( )/3g.>) &M" r+   c                 "    U R                  SS9  g)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`

TrS  NrU  r  s    r(   closeCursorResult.close,  s    ( 	d#r+   c                 \    Xl         U R                  R                  X R                  U5        g r$   )
_yield_perr@  r  rh  )r&   r  s     r(   r  CursorResult.yield_perB  s!    &&t[[#>r+   )r>  r  r$   )r   r   r   r   r   r   r  r<  _cursor_strategy_cls_NO_RESULT_METADATAr  
_is_cursorr"  r%  r(  r+  r.  r3  r;  r   r  r   r  r  s   @r(   r  r    s[    : ,.-JL@G&$, ? ?r+   r  c                   J   ^  \ rS rSrSrSr\r\r	\
r\rS rSU 4S jjrSrU =r$ )LegacyCursorResultiH  zLegacy version of :class:`.CursorResult`.

This class includes connection "connection autoclose" behavior for use with
"connectionless" execution, as well as delivers rows using the
:class:`.LegacyRow` row implementation.

.. versionadded:: 1.4

Fc                 "    U R                  SS9  g)a  Close this :class:`_engine.LegacyCursorResult`.

This method has the same behavior as that of
:meth:`._engine.CursorResult`, but it also may close
the underlying :class:`.Connection` for the case of "connectionless"
execution.

.. deprecated:: 2.0 "connectionless" execution is deprecated and will
   be removed in version 2.0.   Version 2.0 will feature the
   :class:`_future.Result`
   object that will no longer affect the status
   of the originating connection in any case.

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`

    :ref:`dbengine_implicit`
TrS  Nr:  r  s    r(   r;  LegacyCursorResult.closeZ  s    0 	d#r+   c                    > U R                   n[        [        U ]  US9  U(       d?  U R                   (       a-  U R                  (       a  U R
                  R                  5         g g g g rR  )r  rs  rD  rU  _autoclose_connectionrF  r;  )r&   rT  soft_closedr7   s      r(   rU  LegacyCursorResult._soft_closet  sU    '' $33>!!**OO!!# + " r+   r2   r  )r   r   r   r   r   rH  r   r  r   r  r<  r@  _LEGACY_NO_RESULT_METADATAr  r;  rU  r   r  r  s   @r(   rD  rD  H  s6     "L1.4$4$ $r+   rD  c                       \ rS rSrSr\rSrg)BufferedRowResultProxyi  zA ResultProxy with row buffering behavior.

.. deprecated::  1.4 this class is now supplied using a strategy object.
   See :class:`.BufferedRowCursorFetchStrategy`.

r2   N)r   r   r   r   r   rM  r@  r   r2   r+   r(   rM  rM    s     :r+   rM  c                       \ rS rSrSr\rSrg)FullyBufferedResultProxyi  zA result proxy that buffers rows fully upon creation.

.. deprecated::  1.4 this class is now supplied using a strategy object.
   See :class:`.FullyBufferedCursorFetchStrategy`.

r2   N)r   r   r   r   r   r  r@  r   r2   r+   r(   rO  rO    s     <r+   rO  c                       \ rS rSrSrSrg)BufferedColumnRowi  z&Row is now BufferedColumn in all casesr2   N)r   r   r   r   r   r   r2   r+   r(   rQ  rQ    s    0r+   rQ  c                       \ rS rSrSr\rSrg)BufferedColumnResultProxyi  zA ResultProxy with column buffering behavior.

.. versionchanged:: 1.4   This is now the default behavior of the Row
   and this class does not change behavior in any way.

r2   N)r   r   r   r   r   rQ  r  r   r2   r+   r(   rS  rS    s     %Lr+   rS  ):r   rN  r  r   r   r   r   r   r   r    r
   r   sqlr   r   r  sql.baser   sql.compilerr   r   r   r   symbolr   r5   r^   r.   r6   r`   r]   rg   r   r   objectr   r  r/  r?  r6  _NO_CURSOR_DMLr<  _DEFAULT_FETCHrM  r  r  r  rA  rK  r  r  rD  ResultProxyrM  rO  rQ  rS  r2   r+   r(   <module>r]     s  7    " (       " " " % + "[[%

  
 _
@> _
@DkD!5 kD\& D$/ $<4 . *+34 3  *+9;- 9;x %&D;%8 D;N9': 9x$ $@/  () 46 M%v M%`Z?#V Z?z4$ 4$n !:[ :<{ <1	 1% %r+   