
    2ig                        d Z ddlmZ ddlmZmZmZ ddlmZ ddl	m
Z ddlmZmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZ erddlmZ  G d dedef   ee         Zy)z%
psycopg server-side cursor (async).
    )annotations)TYPE_CHECKINGAnyoverload)Iterable   )errors)ParamsQuery)AsyncRowFactoryRow)Self)AsyncCursor)ServerCursorMixin)AsyncConnectionc                      e Zd ZdZdZeddd	 	 	 	 	 	 	 dd       Zeddd	 	 	 	 	 	 	 	 	 dd       Zdddd	 	 	 	 	 	 	 	 	 dd	Zd fd
Z	 ddd	 	 	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 ddZddZ	dddZ
d dZd!dZd"dZd#d$dZ xZS )%AsyncServerCursorpsycopg NF)
scrollablewithholdc                    y Nr   )self
connectionnamer   r   s        [/var/www/html/secretsanta/venv/lib/python3.12/site-packages/psycopg/_server_cursor_async.py__init__zAsyncServerCursor.__init__   s         c                    y r   r   r   r   r   row_factoryr   r   s         r   r   zAsyncServerCursor.__init__'   s     r   )r"   r   r   c                   t        j                  | ||xs |j                         t        j                  | |||       y )N)r"   )r   r   r"   r   r!   s         r   r   zAsyncServerCursor.__init__2   s:     	*+*O9O9O	
 	""4z8Dr   c                  K   | j                   j                  4 d{    | j                  r	 ddd      d{    y| j                   j                  s1| j                   j                  | j	                                d{    t
        |           d{    ddd      d{    y7 7 u7 /7 7 # 1 d{  7  sw Y   yxY ww)zI
        Close the current cursor and free associated resources.
        N)_connlockclosedwait
_close_gensuperclose)r   	__class__s    r   r+   zAsyncServerCursor.close@   s      ::?? 	" 	"{{	" 	" 	" ::$$jjoodoo&7888'-/!!	" 	" 	" 	" 9!	" 	" 	" 	"s   CB/CB9CB1CAB9B3B9B5B9C)B7*C1C3B95B97C9C?C CC)binaryc                 K   |rt        dt        |      d          | j                  j                  rt	        j
                  d      	 | j                  j                  4 d{    | j                  j                  | j                  |||             d{    ddd      d{    | S 7 J7 7 
# 1 d{  7  sw Y   | S xY w# t        j                  $ r}|j                  d      d}~ww xY ww)zC
        Open a cursor to execute a query to the database.
        zkeyword not supported: r   z2server-side cursors not supported in pipeline modeN)	TypeErrorlist_pgconnpipeline_statuseNotSupportedErrorr%   r&   r(   _declare_gen_NO_TRACEBACKwith_traceback)r   queryparamsr-   kwargsexs         r   executezAsyncServerCursor.executeK   s      5d6l1o5FGHH<<''%%D 	*zz P Pjjood&7&7vv&NOOOP P
 POP P P P
   	*##D))	*s   AC8C %B0&C )0B6B2B6C )B4*C .C80C 2B64C 6C	<B?=C	C C8	C C5C00C55C8T)	returningc               4   K   t        j                  d      w)z/Method not implemented for server-side cursors.z0executemany not supported on server-side cursors)r3   r4   )r   r8   
params_seqr=   s       r   executemanyzAsyncServerCursor.executemanye   s      !!"TUUs   c                <  K   | j                   j                  4 d {    | j                   j                  | j                  d             d {   }d d d       d {    r| xj                  dz  c_        |d   S y 7 c7 37 %# 1 d {  7  sw Y   5xY ww)Nr   r   )r%   r&   r(   
_fetch_gen_posr   recss     r   fetchonezAsyncServerCursor.fetchonek   s~     ::?? 	= 	=);<<D	= 	=IINI7N	=<	= 	= 	= 	=sV   BBB.BBBBB "BBBBBBBc                ^  K   |s| j                   }| j                  j                  4 d {    | j                  j                  | j	                  |             d {   }d d d       d {    | xj
                  t              z  c_        |S 7 f7 67 (# 1 d {  7  sw Y   8xY wwr   )	arraysizer%   r&   r(   rB   rC   len)r   sizerE   s      r   	fetchmanyzAsyncServerCursor.fetchmanyt   s     >>D::?? 	@ 	@)>??D	@ 	@		SY		@?	@ 	@ 	@ 	@sV   )B-BB-.BBB"B--B.%B-BB-B*B!B*&B-c                B  K   | j                   j                  4 d {    | j                   j                  | j                  d              d {   }d d d       d {    | xj                  t              z  c_        |S 7 f7 67 (# 1 d {  7  sw Y   8xY wwr   )r%   r&   r(   rB   rC   rI   rD   s     r   fetchallzAsyncServerCursor.fetchall|   s     ::?? 	@ 	@)>??D	@ 	@		SY		@?	@ 	@ 	@ 	@sV   BBB.B
BB
BB %BB
B
BBBBc                    | S r   r   )r   s    r   	__aiter__zAsyncServerCursor.__aiter__   s    r   c                  K   | j                   5| j                  t        | j                         cxk\  r| j                  k\  rzn nw| j                  j
                  4 d {    | j                  j                  | j                  | j                               d {   | _         d| _        d d d       d {    | j                  t        | j                         k\  rt        d      | j                   | j                     }| xj                  dz  c_        | xj                  dz  c_	        |S 7 7 7 z# 1 d {  7  sw Y   xY ww)Nr   zno more records to returnr   )

_iter_rows	_page_posrI   itersizer%   r&   r(   rB   StopAsyncIterationrC   )r   recs     r   	__anext__zAsyncServerCursor.__anext__   s      ??"NNc$//2CdmmCzz # #(,

8V(W"W!"# # >>S11$%@AAoodnn-!		Q	
#"W# # # #s[   AED-E"8D3D/D3+E6D17A7E/D31E3E9D<:EEc                J  K   | j                   j                  4 d {    | j                   j                  | j                  ||             d {    d d d       d {    |dk(  r| xj                  |z  c_        y || _        y 7 j7 97 +# 1 d {  7  sw Y   ;xY ww)Nrelative)r%   r&   r(   _scroll_genrC   )r   valuemodes      r   scrollzAsyncServerCursor.scroll   s     ::?? 	A 	A**//$"2"25$"?@@@	A 	A :IIIDI	A@	A 	A 	A 	AsV   B#BB#/BB
BB# B!(B#
BB#B BB B#)r   zAsyncConnection[Row]r   strr   bool | Noner   bool)
r   AsyncConnection[Any]r   r]   r"   zAsyncRowFactory[Row]r   r^   r   r_   )
r   r`   r   r]   r"   zAsyncRowFactory[Row] | Noner   r^   r   r_   )returnNoner   )
r8   r   r9   zParams | Noner-   r^   r:   r   ra   r   )r8   r   r?   zIterable[Params]r=   r_   ra   rb   )ra   z
Row | None)r   )rJ   intra   	list[Row])ra   rd   )ra   r   )ra   r   )rX   )rZ   rc   r[   r]   ra   rb   )__name__
__module____qualname__	__slots__r   r   r+   r<   r@   rF   rK   rM   rO   rV   r\   __classcell__)r,   s   @r   r   r      s~    JI #'( 
      #'( 
 *     48"&E(E E
 1E  E E	" !%
 # 
   
6 PTVV(8VHLV	V$ r   r   r`   N)__doc__
__future__r   typingr   r   r   collections.abcr    r	   r3   abcr
   r   rowsr   r   _compatr   cursor_asyncr   _server_cursor_baser   connection_asyncr   r   r   r   r   <module>ru      sQ    # / / $   &  % 21G,c12K4DGr   