
    jg                        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dS )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d8d            Zedddd9d            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@dAd/Z
dBd0ZdCd1ZdDd3ZdEdFd7Z xZS )GAsyncServerCursorpsycopg NF)
scrollablewithhold
connectionAsyncConnection[Row]namestrr   bool | Noner   boolc                   d S Nr   )selfr   r   r   r   s        f/workspace/show-city-briefing-agent/.venv/lib/python3.11/site-packages/psycopg/_server_cursor_async.py__init__zAsyncServerCursor.__init__   s	     s    AsyncConnection[Any]row_factoryAsyncRowFactory[Row]c                   d S r   r   r    r   r   r%   r   r   s         r!   r"   zAsyncServerCursor.__init__'   s	     sr#   )r%   r   r   AsyncRowFactory[Row] | Nonec               p    t          j        | ||p|j                   t          j        | |||           d S )N)r%   )r   r"   r%   r   r(   s         r!   r"   zAsyncServerCursor.__init__2   sL     	*+*O9O	
 	
 	
 	
 	"4z8DDDDDr#   returnNonec                x  K   | j         j        4 d{V  | j        r	 ddd          d{V  dS | j         j        s2| j                             |                                            d{V  t                                                       d{V  ddd          d{V  dS # 1 d{V swxY w Y   dS )zI
        Close the current cursor and free associated resources.
        N)_connlockclosedwait
_close_gensuperclose)r    	__class__s    r!   r4   zAsyncServerCursor.close@   s      :? 	" 	" 	" 	" 	" 	" 	" 	"{ 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" :$ 9joodoo&7&7888888888''--//!!!!!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s   	B)A$B))
B36B3)binaryqueryr   paramsParams | Noner6   kwargsr   r   c                 K   |r%t          dt          |          d                    | j        j        rt	          j        d          	 | j        j        4 d{V  | j                            | 	                    |||                     d{V  ddd          d{V  n# 1 d{V swxY w Y   n,# t          j
        $ r}|                    d          d}~ww xY w| S )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/   r1   _declare_gen_NO_TRACEBACKwith_traceback)r    r7   r8   r6   r:   exs         r!   executezAsyncServerCursor.executeK   s       	IGd6ll1oGGHHH<' 	%D  	*z P P P P P P P Pjood&7&7vv&N&NOOOOOOOOOP P P P P P P P P P P P P P P P P P P P P P P P P P P 	* 	* 	*##D)))	* s<   B7 6B%B7 %
B//B7 2B/3B7 7C CC T)	returning
params_seqIterable[Params]rG   c               .   K   t          j        d          )z/Method not implemented for server-side cursors.z0executemany not supported on server-side cursors)r@   rA   )r    r7   rH   rG   s       r!   executemanyzAsyncServerCursor.executemanye   s       !"TUUUr#   
Row | Nonec                  K   | j         j        4 d {V  | j                             |                     d                     d {V }d d d           d {V  n# 1 d {V swxY w Y   |r| xj        dz  c_        |d         S d S )Nr   r   )r.   r/   r1   
_fetch_gen_posr    recss     r!   fetchonezAsyncServerCursor.fetchonek   s     :? 	= 	= 	= 	= 	= 	= 	= 	=););<<<<<<<<D	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	IINII7N4   4A
A%(A%r   sizeint	list[Row]c                (  K   |s| j         }| j        j        4 d {V  | j                            |                     |                     d {V }d d d           d {V  n# 1 d {V swxY w Y   | xj        t          |          z  c_        |S r   )	arraysizer.   r/   r1   rN   rO   len)r    rT   rQ   s      r!   	fetchmanyzAsyncServerCursor.fetchmanyt   s=      	">D:? 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@)>)>????????D	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@		SYY		s   4A$$
A.1A.c                  K   | j         j        4 d {V  | j                             |                     d                      d {V }d d d           d {V  n# 1 d {V swxY w Y   | xj        t          |          z  c_        |S r   )r.   r/   r1   rN   rO   rY   rP   s     r!   fetchallzAsyncServerCursor.fetchall|   s.     :? 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@)>)>????????D	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@		SYY		rS   c                    | S r   r   )r    s    r!   	__aiter__zAsyncServerCursor.__aiter__   s    r#   r   c                   K   | j         ,| j        t          | j                   cxk    r| j        k    r}n nz| j        j        4 d {V  | j                            |                     | j                             d {V | _         d| _        d d d           d {V  n# 1 d {V swxY w Y   | j        t          | j                   k    rt          d          | j         | j                 }| xj        dz  c_        | xj	        dz  c_	        |S )Nr   zno more records to returnr   )

_iter_rows	_page_posrY   itersizer.   r/   r1   rN   StopAsyncIterationrO   )r    recs     r!   	__anext__zAsyncServerCursor.__anext__   s      ?"Nc$/22CCCCdmCCCCCz # # # # # # # #(,
8V8V(W(W"W"W"W"W"W"W!"# # # # # # # # # # # # # # # # # # # # # # # # # # # >S1111$%@AAAodn-!		Q		
s   AB
B),B)relativevaluemodec                  K   | j         j        4 d {V  | j                             |                     ||                     d {V  d d d           d {V  n# 1 d {V swxY w Y   |dk    r| xj        |z  c_        d S || _        d S )Nrf   )r.   r/   r1   _scroll_genrO   )r    rg   rh   s      r!   scrollzAsyncServerCursor.scroll   sD     :? 	A 	A 	A 	A 	A 	A 	A 	A*//$"2"25$"?"?@@@@@@@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A :IIIIIIDIIIs   5A
A&)A&)r   r   r   r   r   r   r   r   )
r   r$   r   r   r%   r&   r   r   r   r   )
r   r$   r   r   r%   r)   r   r   r   r   )r+   r,   r   )
r7   r   r8   r9   r6   r   r:   r   r+   r   )r7   r   rH   rI   rG   r   r+   r,   )r+   rL   )r   )rT   rU   r+   rV   )r+   rV   )r+   r   )r+   r   )rf   )rg   rU   rh   r   r+   r,   )__name__
__module____qualname__	__slots__r   r"   r4   rF   rK   rR   rZ   r\   r^   re   rk   __classcell__)r5   s   @r!   r   r      s        JI #'     X  #'     X 48"&E E E E E E	" 	" 	" 	" 	" 	" !%
 #     6 PTV V V V V V                $        r#   r   r$   N)__doc__
__future__r   typingr   r   r   collections.abcr    r	   r@   abcr
   r   rowsr   r   _compatr   cursor_asyncr   _server_cursor_baser   connection_asyncr   r   r   r#   r!   <module>r|      s6    # " " " " " / / / / / / / / / / $ $ $ $ $ $               & & & & & & & &       % % % % % % 2 2 2 2 2 2 2111111G G G G G,c12K4DG G G G Gr#   