
    ,h$                       S r SSKJr  SSKJr  SSKJrJrJrJ	r	J
r
  SSKJr  SSKJr  SSKJr  SS	KJrJr  SS
KJrJr  SSKJrJrJr  SSKJr  SSKJr  SSKJ r   \(       a  SSK!J"r"  \RF                  RH                  r$ " S S\S\4   5      r%g)z
Psycopg AsyncCursor object.
    )annotations)TracebackType)TYPE_CHECKINGAnyAsyncIteratorIterableoverload)asynccontextmanager   )errors)pq)ParamsQuery)	AsyncCopyAsyncWriter)AsyncRowFactoryRowRowMaker)Self)
BaseCursor)AsyncPipeline)AsyncConnectionc                    ^  \ rS rSrSrSr\S S j5       r\    S!S j5       rSS.   S"U 4S jjjrS#S	 jr        S$S
 jrS%S jr	\
S&S j5       r\R                  S'S j5       rS(S jr S)SSS.         S*S jjjrSS.       S+S jjr S)SSS.         S,S jjjrS-S jrS.S/S jjrS0S jrS1S jrS2S3S jjr\ S)SS.       S4S jjj5       rS%S jrSrU =r$ )5AsyncCursor   psycopg c                    g Nr   )self
connections     O/var/www/html/Ai_home/venv/lib/python3.13/site-packages/psycopg/cursor_async.py__init__AsyncCursor.__init__    s    :=    c                   g r   r   )r    r!   row_factorys      r"   r#   r$   #   s     r%   N)r'   c               X   > [         TU ]  U5        U=(       d    UR                  U l        g r   )superr#   r'   _row_factory)r    r!   r'   	__class__s      r"   r#   r$   (   s%     	$'A:+A+Ar%   c                   #    U $ 7fr   r   r    s    r"   
__aenter__AsyncCursor.__aenter__1   s
     s   c                @   #    U R                  5       I S h  vN   g  N7fr   )close)r    exc_typeexc_valexc_tbs       r"   	__aexit__AsyncCursor.__aexit__4   s      jjls   c                ,   #    U R                  5         g7f)z9
Close the current cursor and free associated resources.
N)_closer-   s    r"   r1   AsyncCursor.close<   s      	s   c                    U R                   $ )z9Writable attribute to control how result rows are formed.r*   r-   s    r"   r'   AsyncCursor.row_factoryB   s        r%   c                N    Xl         U R                  (       a  U" U 5      U l        g g r   )r*   pgresult	_make_row)r    r'   s     r"   r'   r<   G   s     '==(.DN r%   c                $    U R                  U 5      $ r   r;   r-   s    r"   _make_row_makerAsyncCursor._make_row_makerM   s      &&r%   preparebinaryc          
     l  #     U R                   R                   ISh  vN   U R                   R                  U R                  XX4S95      I Sh  vN   SSS5      ISh  vN   U $  NG N N
! , ISh  vN  (       d  f       U $ = f! [        R
                   a  nUR                  S5      eSnAff = f7f)z-
Execute a query or command to the database.
NrC   )_connlockwait_execute_gene_NO_TRACEBACKwith_traceback)r    queryparamsrD   rE   exs         r"   executeAsyncCursor.executeP   s     	*zzjjoo%%eW%T   '  ' '   	*##D))	*s   B4B A&B -A,A(A,B A* B $B4&B (A,*B ,B2A53B?B B4B B1B,,B11B4F)	returningc          	     R  #     U R                   R                   ISh  vN   [        R                  " 5       (       a  U R                   R                  (       a4  U R                   R                  U R                  XU5      5      I Sh  vN   OU R                   R                  5        ISh  vN   U R                   R                  U R                  XU5      5      I Sh  vN   SSS5      ISh  vN   O3U R                   R                  U R                  XU5      5      I Sh  vN   SSS5      ISh  vN   g GN N N N` NR! , ISh  vN  (       d  f       N3= f N: N,! , ISh  vN  (       d  f       g= f! [        R                   a  nUR                  S5      eSnAff = f7f)z9
Execute the same command with a sequence of input data.
N)rG   rH   r   is_supported	_pipelinerI   _executemany_gen_pipeline_pipeline_nolock_executemany_gen_no_pipelinerK   rL   rM   )r    rN   
params_seqrS   rP   s        r"   executemanyAsyncCursor.executemanyd   s8    	*zz --// zz++"jjoo ::5iX  
 $(::#>#>#@#@"&**// $ > >$)y!"#   $A#@#@ **//99%YW  # '

 $A $A#@#@#@# '(  	*##D))	*s   F'E: D7E: A$E D:#E *D<+E ./ED>E"E -E .3E !E"E &E: 1E2E: 6F'7E: :E <E >E E E	E	E	E E:  E7&E)'E73E: 6F'7E: :F$FF$$F'r   rE   sizec          
    z  #    U R                   R                  (       a  [        R                  " S5      eU R                  R
                   ISh  vN    U R                  R                  U R                  XX4S95      I Sh  vN   SnU R                  R                  U R                  U5      5      I Sh  vN =n(       a  [        UR                  5       H+  nU R                  R                  XpR                  5      7v   M-     SnU R                  R                  U R                  U5      5      I Sh  vN =n(       a  M  U R                   R                   ["        :X  a  U R                  R%                  5       I Sh  vN    U R                  R                  U R                  SS95      I Sh  vN (       a8   U R                  R                  U R                  SS95      I Sh  vN (       a  M8   U R                  R                  U R                  SS95      I Sh  vN   O SSS5      ISh  vN   g GN GN GN GN	! [        R                   a  nUR                  S5      eSnAff = f N N N! [&         a     Nf = f Nf! [&         a     Nnf = f! U R                   R                   ["        :X  a  U R                  R%                  5       I Sh  vN     U R                  R                  U R                  SS95      I Sh  vN  (       a9   U R                  R                  U R                  SS95      I Sh  vN  (       a  M9  O! [&         a     Of = f U R                  R                  U R                  SS95      I Sh  vN    f ! [&         a     f f = ff = f GNq! , ISh  vN  (       d  f       g= f7f)z
Iterate row-by-row on a result from the database.

:param size: if greater than 1, results will be retrieved by chunks of
    this size from the server (but still yielded row-by-row); this is only
    available from version 17 of the libpq.
z(stream() cannot be used in pipeline modeNr]   TF)first)_pgconnpipeline_statusrK   ProgrammingErrorrG   rH   rI   _stream_send_gen_stream_fetchone_genrangentuples_txload_rowr?   rL   rM   transaction_statusACTIVE_try_cancel	Exception)	r    rN   rO   rE   r^   r`   resposrP   s	            r"   streamAsyncCursor.stream   s     <<''$$%OPP::???jjoo))%)R   #'::??43L3LU3S#TTTcT$S[[1"hh//^^DD  2!E $(::??43L3LU3S#TTTcT <<22f< **00222$(JJOO 55E5B%   ! %)JJOO 55E5B%  "jjood.G.Ge.G.TUUU = #?? U ?? .''--. 3 %  V$ ! <<22f< **00222$(JJOO 55E5B%   ! %)JJOO 55E5B%    % 
"jjood.G.Ge.G.TUUU$ ! = #???s  AN;H3N;N!,H? H63H?4H95A>H?3H<4H?;N!<I,=N!+I2-I..5I2#I0$	I20+JJJ N!"N;-N.N;6H?9H?<H??I)I$$I))J,N!.I20I22
I?<N!>I??N!J
JN!JN!<NK
N+ML
6M9L<
:
MN
M	NM	N+N
N
N
	N

N	NN	NN!N;!N8'N*(N84N;c                "  #    U R                  5       I Sh  vN   U R                  5       nU R                  UR                  :  aG  U R                  R                  U R                  U R                  5      nU =R                  S-  sl        U$ g Nv7f)z
Return the next record from the current recordset.

Return `!None` the recordset is finished.

:rtype: Row | None, with Row defined by `row_factory`
Nr   _fetch_pipeline_check_result_for_fetch_posrg   rh   ri   r?   )r    rn   records      r"   fetchoneAsyncCursor.fetchone   so      ""$$$**,99s{{"XX&&tyy$..AFIINIM 	%s   BBA7Bc                h  #    U R                  5       I Sh  vN   U R                  5       nU(       d  U R                  nU R                  R	                  U R
                  [        U R
                  U-   UR                  5      U R                  5      nU =R
                  [        U5      -  sl        U$  N7f)z
Return the next `!size` records from the current recordset.

`!size` default to `!self.arraysize` if not specified.

:rtype: Sequence[Row], with Row defined by `row_factory`
N)
rt   ru   	arraysizerh   	load_rowsrv   minrg   r?   len)r    r^   rn   recordss       r"   	fetchmanyAsyncCursor.fetchmany   s      ""$$$**,>>D(($$IIs499t+S[[94>>
 			S\!	 	%s   B2B0BB2c                   #    U R                  5       I Sh  vN   U R                  5       nU R                  R                  U R                  UR
                  U R                  5      nUR
                  U l        U$  Nb7f)zx
Return all the remaining records from the current recordset.

:rtype: Sequence[Row], with Row defined by `row_factory`
N)rt   ru   rh   r|   rv   rg   r?   )r    rn   r   s      r"   fetchallAsyncCursor.fetchall   s`      ""$$$**,(($$TYYT^^LKK		 	%s   A;A9A#A;c               b  #    U R                  5       I S h  vN   U R                  5       nU R                  UR                  :  ag  U R                  R                  U R                  U R                  5      nU =R                  S-  sl        U7v   U R                  UR                  :  a  Mf  g g  N7f)Nr   rs   )r    rn   rows      r"   	__aiter__AsyncCursor.__aiter__   s|     ""$$$**,ii#++%((##DIIt~~>CIINII ii#++% 	%s   B/B-BB/+B/c                b   #    U R                  5       I Sh  vN   U R                  X5        g N7f)av  
Move the cursor in the result set to a new position according to mode.

If `!mode` is ``'relative'`` (default), `!value` is taken as offset to
the current position in the result set; if set to ``'absolute'``,
`!value` states an absolute target position.

Raise `!IndexError` in case a scroll operation would leave the result
set. In this case the position will not change.
N)rt   _scroll)r    valuemodes      r"   scrollAsyncCursor.scroll   s*      ""$$$U! 	%s   /-/writerc                #     U R                   R                   ISh  vN   U R                   R                  U R                  X5      5      I Sh  vN   SSS5      ISh  vN   [	        XS9 ISh  vN nU7v   SSS5      ISh  vN   U R                  S5        g N NO NA! , ISh  vN  (       d  f       NV= f NK N8! , ISh  vN  (       d  f       NM= f! [
        R                   a  nUR                  S5      eSnAff = f7f)zE
Initiate a :sql:`COPY` operation and return an object to manage it.
Nr   r   )	rG   rH   rI   _start_copy_genr   rK   rL   rM   _select_current_result)r    	statementrO   r   copyrP   s         r"   r   AsyncCursor.copy   s     	*zzjjood&:&:9&MNNN ' !55
 65 	##A& 'N ' 6555 	*##D))	*s   D	C BC .B$B B$C  B"!C 2B>3C 6C<C C C D	C  B$"C $B;*B-+B;7C  C CC	CC D	C D0DDD	c                  #    U R                   SLa  U R                  (       d  U R                  R                  (       at  U R                  R                   IS h  vN   U R                  R                  U R                  R                  R                  SS95      I S h  vN   S S S 5      IS h  vN   g g g g  N\ N N! , IS h  vN  (       d  f       g = f7f)NFT)flush)_execmany_returningr>   rG   rV   rH   rI   
_fetch_genr-   s    r"   rt   AsyncCursor._fetch_pipeline  s     $$E1MM

$$zzjjoodjj&:&:&E&ED&E&QRRR ' % " 2 'R 's[   ACB5CA B;B7B;!C,B9-	C7B;9C;CCCC)r?   rv   r*   )r!   zAsyncConnection[Row])r!   AsyncConnection[Any]r'   AsyncRowFactory[Row])r!   r   r'   zAsyncRowFactory[Row] | None)returnr   )r2   ztype[BaseException] | Noner3   zBaseException | Noner4   zTracebackType | Noner   None)r   r   )r   r   )r'   r   r   r   )r   zRowMaker[Row]r   )
rN   r   rO   Params | NonerD   bool | NonerE   r   r   r   )rN   r   rZ   zIterable[Params]rS   boolr   r   )
rN   r   rO   r   rE   r   r^   intr   AsyncIterator[Row])r   z
Row | None)r   )r^   r   r   	list[Row])r   r   )r   r   )relative)r   r   r   strr   r   )r   r   rO   r   r   zAsyncWriter | Noner   zAsyncIterator[AsyncCopy])__name__
__module____qualname____firstlineno__	__slots__r	   r#   r.   r5   r1   propertyr'   setterrA   rQ   r[   rp   rx   r   r   r   r   r
   r   rt   __static_attributes____classcell__)r+   s   @r"   r   r      s   JI= =.@T  48	B(B 1	B B, & %	
 
 ! ! / /
' !%
  $" 
   
* PU**(8*HL*	*B !%0
 #00 0
 0 0 
0d &
"  !%'
 &*'' '
 #' 
"' '.S Sr%   r   r   N)&__doc__
__future__r   typesr   typingr   r   r   r   r	   
contextlibr
    r   rK   r   abcr   r   r   r   r   rowsr   r   r   _compatr   _cursor_baser   _pipeline_asyncr   connection_asyncr   TransactionStatusrk   r   r   r%   r"   <module>r      sh    #  H H *    ( 0 0  $ *1				$	$}S*3S89 }Sr%   