
    (phE                       S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	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  SSKJrJrJrJrJrJrJr  SSKJr  SSK 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K0J1r1  SSK2J3r3  SSK4J5r5  SSK6J7r7  SSK8J9r9  SSK:J;r;  SSK<J=r=J>r>J?r?   SSK@r@SSKArASSKAJBrB  SSK)JCrC  \(       a  SSKEJFrF  SrG\R                  R                  rI\R                  R                  rJ\R                  R                  rL\R                  R                  rM\R                  R                  rN \AR                  \P4rQ\R                  " S5      rS " S  S!\=\!   5      rTg)"z+
Psycopg connection object (async version)
    )annotationsN)	monotonic)TracebackType)AnyAsyncGeneratorAsyncIteratorcastoverloadTYPE_CHECKING)asynccontextmanager   )pq)errors)waiting)AdaptContextConnDict	ConnParamParamsPQGenQueryRV)Xid)RowAsyncRowFactory	tuple_rowargs_row)AdaptersMap)IsolationLevel)Self)make_conninfoconninfo_to_dict)conninfo_attempts_asynctimeout_from_conninfo)AsyncPipeline)notifies)AsyncTransaction)AsyncCursor)capabilities)AsyncServerCursor)BaseConnection	CursorRowNotify)Lock)	to_thread)PGconng?psycopgc                  F  ^  \ rS rSr% SrSrS\S'   S\S'   S\S	'   S
\S'   \" \\   \	5      4   S;U 4S jjjr
\ S<SSSSSS.               S=S jjj5       rS>S jr        S?S jr\S@S j5       rSAS jr\SS.SBS jj5       r\SS.     SCS jj5       r\SSSS.         SDS jj5       r\SSSS.           SES jj5       r S<SSSSS.           SFS jjjr SGSSS.         SHS jjjrSAS  jrSAS! jrS"S#.SIS$ jjrS%S#.SIS& jjr\ SJ     SKS' jj5       rSSS(.     SLS) jjr\SMS* j5       r\4SNS+ jjrSOS, jrSOS- jrSPS. jr SPS/ jr!SQS0 jr"SQS1 jr#SQS2 jr$SQS3 jr% SRS4 jr&SSS5 jr'SAS6 jr(SGSTS7 jjr)SGSTS8 jjr*SUS9 jr+S:r,U =r-$ )VAsyncConnection>   z+
Wrapper for a connection to the database.
r0   ztype[AsyncCursor[Row]]cursor_factoryztype[AsyncServerCursor[Row]]server_cursor_factoryAsyncRowFactory[Row]row_factoryzAsyncPipeline | None	_pipelinec                z   > [         TU ]  U5        X l        [        5       U l        [
        U l        [        U l        g N)	super__init__r7   r-   lockr'   r4   r)   r5   )selfpgconnr7   	__class__s      K/var/www/html/venv/lib/python3.13/site-packages/psycopg/connection_async.pyr<   AsyncConnection.__init__J   s1    
 	 &F	)%6"    F   N)
autocommitprepare_thresholdcontextr7   r4   c                 #     [         R                  S:X  aJ  [        R                  " 5       n[	        U[        R
                  5      (       a  [        R                  " S5      eU R                  " U40 UD6I Sh  vN n	[        U	5      n
Sn[        U	5      I Sh  vN nU H?  n [        S0 UD6nU R                  XS9n[        R                  " U[        S9I Sh  vN n  O   U(       d  W(       d   eUR-                  S5      e[/        U5      Ul        U(       a  X[l        U(       a  Xkl        U(       a  [7        UR8                  5      Ul        X;l        U$  N N N! [        R                    al  n[#        U5      S:  aO  [$        R'                  SUR)                  S5      UR)                  S	5      UR)                  S
5      [+        U5      5        Un SnAGM8  SnAff = f7f)zK
Connect to a database server and return a new `AsyncConnection` instance.
win32zPsycopg cannot use the 'ProactorEventLoop' to run in async mode. Please use a compatible event loop, for instance by setting 'asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())'Ntimeoutintervalr   z=connection attempt failed: host: %r port: %r, hostaddr %r: %shostporthostaddr )sysplatformasyncioget_running_loop
isinstanceProactorEventLoopeInterfaceError_get_connection_paramsr#   r"   r    _connect_genr   wait_conn_async_WAIT_INTERVAL_NO_TRACEBACKlenloggerdebuggetstrwith_tracebackbool_autocommitr7   r4   r   adapters	_adaptersrF   )clsconninforE   rF   rG   r7   r4   kwargsloopparamsrK   rvattemptsattemptgenexlast_exs                    rA   connectAsyncConnection.connectU   s     ||w&//1dG$=$=>>**>  11(EfEE'/088G(7w7&&x&A"223PP !  $ N7((..j)(N .&w'7'78BL0	E F 9
 Q?? 	x=1$LLWF+F+J/B 	sb   A6G8E9GE	G#6EEEA9GGEG0A GGGGc                   #    U $ 7fr:    r>   s    rA   
__aenter__AsyncConnection.__aenter__   s
     s   c                ^  #    U R                   (       a  g U(       a   U R                  5       I S h  vN   OU R                  5       I S h  vN   [        U SS 5      (       d  U R                  5       I S h  vN   g g  NI! [         a   n[        R	                  SX5         S nANSS nAff = f N_ N77f)Nz#error ignored in rollback on %s: %s_pool)closedrollback	Exceptionra   warningcommitgetattrclose)r>   exc_typeexc_valexc_tbexc2s        rA   	__aexit__AsyncConnection.__aexit__   s      ;;Rmmo%% ++- tWd++**, , & RDdQQR   s[   B-A< A:A< B-	B)
)B-3B+4B-:A< <
B&B!B-!B&&B-+B-c                "   #    [        U40 UD6$ 7f)z3Manipulate connection parameters before connecting.)r!   )rj   rk   rl   s      rA   r[   &AsyncConnection._get_connection_params   s       3F33s   c                r   #    U R                   (       a  gSU l        U R                  R                  5         g7f)zClose the database connection.NT)r~   _closedr?   finishry   s    rA   r   AsyncConnection.close   s(     ;; 	s   57)binaryc                   g r:   rx   )r>   r   s     rA   cursorAsyncConnection.cursor   s    CFrC   c                   g r:   rx   )r>   r   r7   s      rA   r   r      s     "%rC   )r   
scrollablewithholdc                   g r:   rx   )r>   namer   r   r   s        rA   r   r      s     "%rC   c                   g r:   rx   )r>   r   r   r7   r   r   s         rA   r   r      s     (+rC   )r   r7   r   r   c                   U R                  5         U(       d  U R                  nU(       a  U R                  U UUUUS9nOU R                  XS9nU(       a  [        Ul        U$ )zL
Return a new `AsyncCursor` to send commands and queries to the connection.
)r   r7   r   r   r7   )_check_connection_okr7   r5   r4   BINARYformat)r>   r   r   r7   r   r   curs          rA   r   r      sk     	!!#**K ,,'%! - C %%d%DCCJ
rC   )preparer   c                  #     U R                  5       nU(       a  [        Ul        UR                  XUS9I Sh  vN $  N! [        R
                   a  nUR                  S5      eSnAff = f7f)z8Execute a query and return a cursor to read its results.)r   N)r   r   r   executerY   r_   re   )r>   queryrn   r   r   r   rs   s          rA   r   AsyncConnection.execute   s\     	*++-C#
UGDDDD 	*##D))	*s5   A-5A  >A  A-A   A*A%%A**A-c                   #    U R                    ISh  vN   U R                  U R                  5       5      I Sh  vN   SSS5      ISh  vN   g N< N N	! , ISh  vN  (       d  f       g= f7f)z/Commit any pending transaction to the database.N)r=   wait_commit_genry   s    rA   r   AsyncConnection.commit  s@     999))D,,./// 99/ 999S   A0AA0#AAAA0
AA0AA0A-AA-)A0c                   #    U R                    ISh  vN   U R                  U R                  5       5      I Sh  vN   SSS5      ISh  vN   g N< N N	! , ISh  vN  (       d  f       g= f7f)z2Roll back to the start of any pending transaction.N)r=   r   _rollback_genry   s    rA   r   AsyncConnection.rollback  s@     999))D..0111 991 999r   g      >@rJ   c                 #    U R                  5       (       d  g[        R                  " 5       (       a/  [        R                  " U R                  US9[        S9I Sh  vN   g [        U R                  5      I Sh  vN   g N$ N7f)ak  Cancel the current operation on the connection.

:param timeout: raise a `~errors.CancellationTimeout` if the
    cancellation request does not succeed within `timeout` seconds.

Note that a successful cancel attempt on the client is not a guarantee
that the server will successfully manage to cancel the operation.

This is a non-blocking version of `~Connection.cancel()` which
leverages a more secure and improved cancellation feature of the libpq,
which is only available from version 17.

If the underlying libpq is older than version 17, the method will fall
back to using the same implementation of `!cancel()`.
NrJ   rL   )	_should_cancelr(   has_cancel_safer   r]   _cancel_genr^   r.   cancel)r>   rK   s     rA   cancel_safeAsyncConnection.cancel_safe  st       ""$$''))))   1N   ,,,
 -s$   ABBB;B<BB      @c                  #     U R                  US9I S h  vN   g  N! [         a   n[        R                  SU5         S nAg S nAff = f7f)NrJ   zquery cancellation failed: %s)r   r   ra   r   )r>   rK   rs   s      rA   _try_cancelAsyncConnection._try_cancel5  sE     	@""7"333 	@NN:B??	@s5   A  A 
AAAAAc           	    \  #    [        XU5      nU R                  (       as  U R                  5        ISh  vN   U ISh  vN   U R                  5        ISh  vN   U7v   SSS5      ISh  vN   SSS5      ISh  vN   SSS5      ISh  vN   gU ISh  vN   U7v   SSS5      ISh  vN   g N Nv N_ NL! , ISh  vN  (       d  f       Na= f NX! , ISh  vN  (       d  f       Nm= f Nd! , ISh  vN  (       d  f       g= f Nt Na! , ISh  vN  (       d  f       g= f7f)ak  
Start a context block with a new transaction or nested transaction.

:param savepoint_name: Name of the savepoint used to manage a nested
    transaction. If `!None`, one will be chosen automatically.
:param force_rollback: Roll back the transaction at the end of the
    block even if there were no error (e.g. to try a no-op process).
:rtype: AsyncTransaction
N)r&   r8   pipeline)r>   savepoint_nameforce_rollbacktxs       rA   transactionAsyncConnection.transaction;  s      dNC>>}}DMMOO -<O r rr 'OOOO rrrs  2D,B4D,C4B6 C4CB8
CB<"C-B:.C2C4=C>C4D,C2D,DD,D#D,.D/D,6C48C:C<CCCCC4C/	C!C/	+C42D,4D:C=;DD,D,D)DD)%D,)rK   
stop_afterc                #    Ub  [        5       U-   n[        U[        5      nOSn[        nSnU R                   ISh  vN   U R                  R
                  n  U R                  [        U R                  5      US9I Sh  vN nU HV  n	[        U	R                  R                  U5      U	R                  R                  U5      U	R                  5      n
U
7v   US-  nMX     Ub  XR:  a  O+U(       a"  [        [        U[        5       -
  5      nUS:  a  OM  SSS5      ISh  vN   g N N! [        R                   a  nUR                  S5      eSnAff = f N6! , ISh  vN  (       d  f       g= f7f)ac  
Yield `Notify` objects as soon as they are received from the database.

:param timeout: maximum amount of time to wait for notifications.
    `!None` means no timeout.
:param stop_after: stop after receiving this number of notifications.
    You might actually receive more than this number if more than one
    notifications arrives in the same packet.
Nr   rL   r   g        )r   minr^   r=   r?   	_encodingr   r%   rY   r_   re   r,   relnamedecodeextrabe_pid)r>   rK   r   deadlinerM   	nreceivedencnsrs   pgnns              rA   r%   AsyncConnection.notifiesP  s7      {W,H7N3HH%H	999++''C2#yy$++)>yRRB
 C**3/1A1A#1F

A GNI  )i.E ">8ik3IJH#~/  99 S 2++D112 999s|   <E4D'E4E&D+D)D+BEE4!E"E4)D++E?EEEE4E1 E#!E1-E4c           	    "  #    U R                    ISh  vN   U R                  5         U R                  nUc  [        U 5      =ol        SSS5      ISh  vN    W ISh  vN   U7v   SSS5      ISh  vN   UR                  S:X  a=  U R                    ISh  vN   XR                  L d   eSU l        SSS5      ISh  vN   gg N Nu! , ISh  vN  (       d  f       N= f N Nr! , ISh  vN  (       d  f       N= f Ni ND! , ISh  vN  (       d  f       g= f! WR                  S:X  aY  U R                    ISh  vN    XR                  L d   eSU l        SSS5      ISh  vN    f ! , ISh  vN  (       d  f       f = ff = f7f)z<Context manager to switch the connection into pipeline mode.Nr   )r=   r   r8   r$   level)r>   r   s     rA   r   AsyncConnection.pipeline  s      999%%'~~H,9$,??> 9	*x  x ~~"999#~~555%)DN %99 # 999  xxx %999 ~~"999#~~555%)DN %99999 #s(  FCF1CFC	FD! C% D! #C))D! 4C'5D! 9 FDFD5F DF	FC"CC"F%D! 'D! )D /C20D <D! FFDDDF!!FE
FE1F*E-+F1F7E:8FFFc                  #     [         R                  " XR                  R                  US9I Sh  vN $  N! [         a    U R                  R
                  [        :X  af  U R                  SS9I Sh  vN     [         R                  " XR                  R                  US9I Sh  vN    e ! [        R                   a     e f = fe f = f7f)z
Consume a generator operating on the connection.

The function must be used on generators that don't change connection
fd (i.e. not on connect and reset).
rL   Nr   rJ   )
r   
wait_asyncr?   socket_INTERRUPTEDtransaction_statusACTIVEr   rY   QueryCanceled)r>   rr   rM   s      rA   r   AsyncConnection.wait  s     	 ++C1C1ChWWWW 		{{--7 &&s&333!,,S++2D2DxXXX   		sa   C
,7 57 C
7 :C1A42C8,B+$B'%B+*C+C?CCCC
c                (     U R                  S5        g )NrE   )_no_set_asyncset_autocommitr>   values     rA   _set_autocommitAsyncConnection._set_autocommit      |,rC   c                   #    U R                    ISh  vN   U R                  U R                  U5      5      I Sh  vN   SSS5      ISh  vN   g N= N N	! , ISh  vN  (       d  f       g= f7f)z6Method version of the `~Connection.autocommit` setter.N)r=   r   _set_autocommit_genr   s     rA   r   AsyncConnection.set_autocommit  B     999))D44U;<<< 99< 999T   A1AA1$AAA A1AA1AA1A.A A.*A1c                (     U R                  S5        g )Nisolation_level)r   set_isolation_levelr   s     rA   _set_isolation_level$AsyncConnection._set_isolation_level  s    01rC   c                   #    U R                    ISh  vN   U R                  U R                  U5      5      I Sh  vN   SSS5      ISh  vN   g N= N N	! , ISh  vN  (       d  f       g= f7f)z;Method version of the `~Connection.isolation_level` setter.N)r=   r   _set_isolation_level_genr   s     rA   r   #AsyncConnection.set_isolation_level  sB     999))D99%@AAA 99A 999r   c                (     U R                  S5        g )N	read_only)r   set_read_onlyr   s     rA   _set_read_onlyAsyncConnection._set_read_only  s    {+rC   c                   #    U R                    ISh  vN   U R                  U R                  U5      5      I Sh  vN   SSS5      ISh  vN   g N= N N	! , ISh  vN  (       d  f       g= f7f)z5Method version of the `~Connection.read_only` setter.N)r=   r   _set_read_only_genr   s     rA   r   AsyncConnection.set_read_only  sB     999))D33E:;;; 99; 999r   c                (     U R                  S5        g )N
deferrable)r   set_deferrabler   s     rA   _set_deferrableAsyncConnection._set_deferrable  r   rC   c                   #    U R                    ISh  vN   U R                  U R                  U5      5      I Sh  vN   SSS5      ISh  vN   g N= N N	! , ISh  vN  (       d  f       g= f7f)z6Method version of the `~Connection.deferrable` setter.N)r=   r   _set_deferrable_genr   s     rA   r   AsyncConnection.set_deferrable  r   r   c                (    [        SU< SU S35      e)Nz'the zD property is read-only on async connections: please use 'await .set_z()' instead.)AttributeError)r>   	attributes     rA   r   AsyncConnection._no_set_async  s(     	} %++4+\C rC   c                   #    U R                    ISh  vN   U R                  U R                  U5      5      I Sh  vN   SSS5      ISh  vN   g N= N N	! , ISh  vN  (       d  f       g= f7f)z?
Begin a TPC transaction with the given transaction ID `!xid`.
N)r=   r   _tpc_begin_genr>   xids     rA   	tpc_beginAsyncConnection.tpc_begin  sD      999))D//4555 995 999r   c                ^  #     U R                    ISh  vN   U R                  U R                  5       5      I Sh  vN   SSS5      ISh  vN   g N< N N	! , ISh  vN  (       d  f       g= f! [        R                   a%  n[        R
                  " [        U5      5      SeSnAff = f7f)zF
Perform the first phase of a transaction started with `tpc_begin()`.
N)r=   r   _tpc_prepare_genrY   ObjectNotInPrerequisiteStateNotSupportedErrorrd   )r>   rs   s     rA   tpc_prepareAsyncConnection.tpc_prepare  sq     	9yyyii 5 5 7888 !yy8 !yyy-- 	9%%c"g.D8	9s   B-A1 AA1 #AAA A1 AA1 B-A1 AA1 A.A A.*A1 -B-.A1 1B* B%%B**B-c                   #    U R                    ISh  vN   U R                  U R                  SU5      5      I Sh  vN   SSS5      ISh  vN   g N> N N	! , ISh  vN  (       d  f       g= f7f)z*
Commit a prepared two-phase transaction.
NCOMMITr=   r   _tpc_finish_genr  s     rA   
tpc_commitAsyncConnection.tpc_commit  sF      999))D003?@@@ 99@ 999T   A2AA2%AAAA2AA2AA2A/A!A/+A2c                   #    U R                    ISh  vN   U R                  U R                  SU5      5      I Sh  vN   SSS5      ISh  vN   g N> N N	! , ISh  vN  (       d  f       g= f7f)z-
Roll back a prepared two-phase transaction.
NROLLBACKr  r  s     rA   tpc_rollbackAsyncConnection.tpc_rollback  sF      999))D00SABBB 99B 999r  c                (  #    U R                  5         U R                  R                  nU R                  [	        [
        R                  5      S9 IS h  vN nUR                  [
        R                  " 5       5      I S h  vN   UR                  5       I S h  vN nS S S 5      IS h  vN   U[        :X  a6  U R                  R                  [        :X  a  U R                  5       I S h  vN   W$  N Np NZ NL! , IS h  vN  (       d  f       Na= f N(7f)Nr   )
_check_tpcinfor   r   r   r   _from_recordr   _get_recover_queryfetchallIDLEINTRANSr   )r>   statusr   ress       rA   tpc_recoverAsyncConnection.tpc_recover  s     --;;8C4D4D+E;FF#++c446777&C GF T>dii::gE--/!!
 G7& GFFF
 "sx   ADC.D(C6?C0 C6C2C6D'C4(?D'D(D0C62C64D6D<C?=D	D)r   r8   r4   r=   r7   r5   )r?   r/   r7   r6   rQ   )rk   rd   rE   rf   rF   
int | NonerG   zAdaptContext | Noner7   zAsyncRowFactory[Row] | Noner4   ztype[AsyncCursor[Row]] | Nonerl   r   returnr   )r'  r   )r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | Noner'  None)rk   rd   rl   r   r'  r   )r'  r(  )r   rf   r'  AsyncCursor[Row])r   rf   r7   AsyncRowFactory[CursorRow]r'  zAsyncCursor[CursorRow])
r   rd   r   rf   r   bool | Noner   rf   r'  zAsyncServerCursor[Row])r   rd   r   rf   r7   r*  r   r+  r   rf   r'  zAsyncServerCursor[CursorRow])r   rd   r   rf   r7   zAsyncRowFactory[Any] | Noner   r+  r   rf   r'  z)AsyncCursor[Any] | AsyncServerCursor[Any]r:   )
r   r   rn   zParams | Noner   r+  r   rf   r'  r)  )rK   floatr'  r(  )NF)r   z
str | Noner   rf   r'  zAsyncIterator[AsyncTransaction])rK   float | Noner   r&  r'  zAsyncGenerator[Notify, None])r'  zAsyncIterator[AsyncPipeline])rr   z	PQGen[RV]rM   r-  r'  r   )r   rf   r'  r(  )r   zIsolationLevel | Noner'  r(  )r   r+  r'  r(  )r  rd   r'  r(  )r  z	Xid | strr'  r(  )r  zXid | str | Noner'  r(  )r'  z	list[Xid]).__name__
__module____qualname____firstlineno____doc____annotations__r	   r   r   r   r<   classmethodru   rz   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$  __static_attributes____classcell__)r@   s   @rA   r2   r2   >   s    J**77%%##
 -11Ey,Q	7	7 *	7 	7  ; !()'+378<;; 	;
 &; %; 1; 6; ; 
; ;z, & %	
 
. 4 4 ',F F %%%4N%	% % 
 "&%% 	%
  % % 
 % % 
 "&++ 	+
 0+  + + 
&+ +   37"&   	 
 1       
3 J !%*
  $** *
 * * 
*&0
2
 59 : 58 @ HM(AE	( * *.0&0;E0	%0d * *& CQ ('=
,B
&<
'=
 	69AC
 
rC   r2   )Ur2  
__future__r   loggingtimer   typesr   typingr   r   r   r	   r
   r   
contextlibr   rR   r   r   rY   r   abcr   r   r   r   r   r   r   _tpcr   rowsr   r   r   r   adaptr   _enumsr   _compatr   rk   r    r!   r"   r#   r8   r$   
generatorsr%   r   r&   cursor_asyncr'   _capabilitiesr(   server_cursorr)   _connection_baser*   r+   r,   rS   rU   r-   r.   	threadingpq.abcr/   r^   FormatTEXTr   TransactionStatusr   r   r!  CancelledErrorKeyboardInterruptr   	getLoggerra   r2   rx   rC   rA   <module>rP     s   #    T T *    L L L  ; ;  "  5 D $   ) % ' , ? ?" 	yy~~				  				$	$



&
&**,=>L 
		9	%InS) IrC   