
    (phI=                       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@JArA  \(       a  SSKBJCrC  SrD\R                  R                  rF\R                  R                  rG\R                  R                  rI\R                  R                  rJ\R                  R                  rK\LrM\R                  " S5      rO " S S \=\!   5      rPg)!z*
Psycopg connection object (sync version)
    )annotationsN)	monotonic)TracebackType)Any	GeneratorIteratorcastoverloadTYPE_CHECKING)contextmanager   )pq)errors)waiting)AdaptContextConnDict	ConnParamParamsPQGenQueryRV)Xid)Row
RowFactory	tuple_rowargs_row)AdaptersMap)IsolationLevel)Self)make_conninfoconninfo_to_dict)conninfo_attemptstimeout_from_conninfo)Pipeline)notifies)Transaction)Cursor)capabilities)ServerCursor)BaseConnection	CursorRowNotify)Lock)PGconng?psycopgc                  :  ^  \ 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S@S jr\SS.SAS jj5       r\SS.     SBS jj5       r\SSSS.         SCS jj5       r\SSSS.           SDS jj5       r S;SSSSS.           SES jjjr SFSSS.         SGS jjjrS@S  jrS@S! jrS"S#.SHS$ jjrS%S#.SHS& jjr\ SI     SJS' jj5       rSSS(.     SKS) jjr\SLS* j5       r\4SMS+ jjrSNS, jrSNS- jrSOS. jr SOS/ jr!SPS0 jr"SPS1 jr#SPS2 jr$SPS3 jr%SQS4 jr&S@S5 jr'SFSRS6 jjr(SFSRS7 jjr)SSS8 jr*S9r+U =r,$ )T
Connection8   z+
Wrapper for a connection to the database.
r/   ztype[Cursor[Row]]cursor_factoryztype[ServerCursor[Row]]server_cursor_factoryRowFactory[Row]row_factoryzPipeline | None	_pipelinec                z   > [         TU ]  U5        X l        [        5       U l        [
        U l        [        U l        g N)	super__init__r6   r-   lockr'   r3   r)   r4   )selfpgconnr6   	__class__s      E/var/www/html/venv/lib/python3.13/site-packages/psycopg/connection.pyr;   Connection.__init__D   s1    
 	 &F	$%1"    F   N)
autocommitprepare_thresholdcontextr6   r3   c                  U R                   " U40 UD6n[        U5      n	Sn
[        U5      nU H7  n [        S	0 UD6nU R	                  XS9n[
        R                  " U[        S9n
  O   U
(       d  W(       d   eUR                  S5      e[!        U5      U
l        U(       a  XZl        U(       a  Xjl        U(       a  [)        UR*                  5      U
l        X:l        U
$ ! [        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M*  SnAff = f)
zF
Connect to a database server and return a new `Connection` instance.
Ntimeoutintervalr   z=connection attempt failed: host: %r port: %r, hostaddr %r: %shostporthostaddr )_get_connection_paramsr#   r"   r    _connect_genr   	wait_conn_WAIT_INTERVALe_NO_TRACEBACKlenloggerdebuggetstrwith_tracebackbool_autocommitr6   r3   r   adapters	_adaptersrE   )clsconninforD   rE   rF   r6   r3   kwargsparamsrI   rvattemptsattemptgenexlast_exs                   r@   connectConnection.connectO   s5     ++H??'/$V,G(7w7&&x&A&&s^D !  $ N7((..j)(N .&w'7'78BL0	3 ?? 	x=1$LLWF+F+J/B 	s   3CE1A EEc                    U $ r9    r=   s    r@   	__enter__Connection.__enter__   s    rB   c                   U R                   (       a  g U(       a   U R                  5         OU R                  5         [        U SS 5      (       d  U R                  5         g g ! [         a   n[        R	                  SX5         S nANIS nAff = f)Nz#error ignored in rollback on %s: %s_pool)closedrollback	ExceptionrX   warningcommitgetattrclose)r=   exc_typeexc_valexc_tbexc2s        r@   __exit__Connection.__exit__   sp     ;;R KKM tWd++JJL ,  RDdQQRs   A   
B
*BB
c                    [        U40 UD6$ )z3Manipulate connection parameters before connecting.)r!   )ra   rb   rc   s      r@   rQ   !Connection._get_connection_params   s      3F33rB   c                j    U R                   (       a  gSU l        U R                  R                  5         g)zClose the database connection.NT)rt   _closedr>   finishro   s    r@   rz   Connection.close   s%    ;; 	rB   )binaryc                   g r9   rn   )r=   r   s     r@   cursorConnection.cursor   s    >ArB   c                   g r9   rn   )r=   r   r6   s      r@   r   r      s      rB   )r   
scrollablewithholdc                   g r9   rn   )r=   namer   r   r   s        r@   r   r      s      rB   c                   g r9   rn   )r=   r   r   r6   r   r   s         r@   r   r      s     #&rB   )r   r6   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$ )zG
Return a new `Cursor` to send commands and queries to the connection.
)r   r6   r   r   r6   )_check_connection_okr6   r4   r3   BINARYformat)r=   r   r   r6   r   r   curs          r@   r   r      sk     	!!#**K ,,'%! - C %%d%DCCJ
rB   )preparer   c                    U R                  5       nU(       a  [        Ul        UR                  XUS9$ ! [        R
                   a  nUR                  S5      eSnAff = f)z8Execute a query and return a cursor to read its results.)r   N)r   r   r   executerU   rV   r\   )r=   queryrd   r   r   r   ri   s          r@   r   Connection.execute   sT    	*++-C#
;;ug;>> 	*##D))	*s   14 AAAc                    U R                      U R                  U R                  5       5        SSS5        g! , (       d  f       g= f)z/Commit any pending transaction to the database.N)r<   wait_commit_genro   s    r@   rx   Connection.commit   s(    YYIId&&() YY	    6
Ac                    U R                      U R                  U R                  5       5        SSS5        g! , (       d  f       g= f)z2Roll back to the start of any pending transaction.N)r<   r   _rollback_genro   s    r@   ru   Connection.rollback  s(    YYIId((*+ YYr   g      >@rH   c                   U R                  5       (       d  g[        R                  " 5       (       a'  [        R                  " U R                  US9[        S9  gU R                  5         g)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()`.
NrH   rJ   )_should_cancelr(   has_cancel_safer   rS   _cancel_genrT   cancel)r=   rI   s     r@   cancel_safeConnection.cancel_safe  sQ      ""$$''))   1N KKMrB         @c               ~     U R                  US9  g ! [         a   n[        R                  SU5         S nAg S nAff = f)NrH   zquery cancellation failed: %s)r   rv   rX   rw   )r=   rI   ri   s      r@   _try_cancelConnection._try_cancel!  s=    	@W- 	@NN:B??	@s    
<7<c              #  p  #    [        XU5      nU R                  (       aB  U R                  5          U   U R                  5          Uv   SSS5        SSS5        SSS5        gU   Uv   SSS5        g! , (       d  f       N/= f! , (       d  f       N8= f! , (       d  f       g= f! , (       d  f       g= f7f)af  
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: Transaction
N)r&   r7   pipeline)r=   savepoint_nameforce_rollbacktxs       r@   transactionConnection.transaction'  sg      ~>>>"dmmo '6"   '6o"" sc   .B6BBA2	BBB6$B%)	B62
B <B
B	B
B"B6%
B3/B6)rI   
stop_afterc             #    #    Ub  [        5       U-   n[        U[        5      nOSn[        nSnU R                     U R                  R
                  n  U R                  [        U R                  5      US9nU HU  n	[        U	R                  R                  U5      U	R                  R                  U5      U	R                  5      n
U
v   US-  nMW     Ub  XR:  a  O+U(       a"  [        [        U[        5       -
  5      nUS:  a  OM  SSS5        g! [        R                   a  nUR                  S5      eSnAff = f! , (       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   rJ   r   g        )r   minrT   r<   r>   	_encodingr   r%   rU   rV   r\   r,   relnamedecodeextrabe_pid)r=   rI   r   deadlinerK   	nreceivedencnsri   pgnns              r@   r%   Connection.notifies<  s(      {W,H7N3HH%H	YY++''C28DKK#88LB
 C**3/1A1A#1F

A GNI  )i.E ">8ik3IJH#~/  Y
  2++D112 YsA   8ED;#D6BD;	ED8"D33D88D;;
E	Ec              #  <  #    U R                      U R                  5         U R                  nUc  [        U 5      =ol        SSS5         W   Uv   SSS5        UR                  S:X  a-  U R                      XR                  L d   eSU l        SSS5        gg! , (       d  f       N\= f! , (       d  f       N]= f! , (       d  f       g= f! WR                  S:X  a>  U R                      XR                  L d   eSU l        SSS5        f ! , (       d  f       f = ff = f7f)z<Context manager to switch the connection into pipeline mode.Nr   )r<   r   r7   r$   level)r=   r   s     r@   r   Connection.pipelinen  s      YY%%'~~H,4TN:> 	*  ~~"YY#~~555%)DN Y # Y  Y ~~"YY#~~555%)DN YY #s|   D1B D	C	 B'C	 D4B8
D
B$ D'
B51C	 8
CD	D&D>	D
DDDc                X    [         R                  " XR                  R                  US9$ ! [         at    U R                  R
                  [        :X  aT  U R                  SS9   [         R                  " XR                  R                  US9  e ! [        R                   a     e f = fe f = 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).
rJ   r   rH   )
r   r   r>   socket_INTERRUPTEDtransaction_statusACTIVEr   rU   QueryCanceled)r=   rh   rK   s      r@   r   Connection.wait  s    	<<[[%7%7(KK 		{{--7    -LLkk&8&88L   		s-   (+ 7B)#)BB)B$!B)#B$$B)c                &    U R                  U5        g r9   )set_autocommitr=   values     r@   _set_autocommitConnection._set_autocommit      E"rB   c                    U R                      U R                  U R                  U5      5        SSS5        g! , (       d  f       g= f)z6Method version of the `~Connection.autocommit` setter.N)r<   r   _set_autocommit_genr   s     r@   r   Connection.set_autocommit  *    YYIId..u56 YY	   !7
Ac                &    U R                  U5        g r9   )set_isolation_levelr   s     r@   _set_isolation_levelConnection._set_isolation_level  s      'rB   c                    U R                      U R                  U R                  U5      5        SSS5        g! , (       d  f       g= f)z;Method version of the `~Connection.isolation_level` setter.N)r<   r   _set_isolation_level_genr   s     r@   r   Connection.set_isolation_level  s*    YYIId33E:; YYr   c                &    U R                  U5        g r9   )set_read_onlyr   s     r@   _set_read_onlyConnection._set_read_only  s    5!rB   c                    U R                      U R                  U R                  U5      5        SSS5        g! , (       d  f       g= f)z5Method version of the `~Connection.read_only` setter.N)r<   r   _set_read_only_genr   s     r@   r   Connection.set_read_only  s*    YYIId--e45 YYr   c                &    U R                  U5        g r9   )set_deferrabler   s     r@   _set_deferrableConnection._set_deferrable  r   rB   c                    U R                      U R                  U R                  U5      5        SSS5        g! , (       d  f       g= f)z6Method version of the `~Connection.deferrable` setter.N)r<   r   _set_deferrable_genr   s     r@   r   Connection.set_deferrable  r   r   c                    U R                      U R                  U R                  U5      5        SSS5        g! , (       d  f       g= f)z?
Begin a TPC transaction with the given transaction ID `!xid`.
N)r<   r   _tpc_begin_genr=   xids     r@   	tpc_beginConnection.tpc_begin  s,     YYIId))#./ YYr   c                    U R                      U R                  U R                  5       5        SSS5        g! , (       d  f       g= f! [        R                   a%  n[        R
                  " [        U5      5      SeSnAff = f)zF
Perform the first phase of a transaction started with `tpc_begin()`.
N)r<   r   _tpc_prepare_genrU   ObjectNotInPrerequisiteStateNotSupportedErrorr[   )r=   ri   s     r@   tpc_prepareConnection.tpc_prepare  sY    	9		$//12 -- 	9%%c"g.D8	9s1   A  7A 
AA A B A<<Bc                    U R                      U R                  U R                  SU5      5        SSS5        g! , (       d  f       g= f)z*
Commit a prepared two-phase transaction.
COMMITNr<   r   _tpc_finish_genr   s     r@   
tpc_commitConnection.tpc_commit  s.     YYIId**8S9: YY	   "8
Ac                    U R                      U R                  U R                  SU5      5        SSS5        g! , (       d  f       g= f)z-
Roll back a prepared two-phase transaction.
ROLLBACKNr   r   s     r@   tpc_rollbackConnection.tpc_rollback  s.     YYIId**:s;< YYr  c                   U R                  5         U R                  R                  nU R                  [	        [
        R                  5      S9 nUR                  [
        R                  " 5       5        UR                  5       nS S S 5        U[        :X  a.  U R                  R                  [        :X  a  U R                  5         W$ ! , (       d  f       NH= f)Nr   )
_check_tpcinfor   r   r   r   _from_recordr   _get_recover_queryfetchallIDLEINTRANSru   )r=   statusr   ress       r@   tpc_recoverConnection.tpc_recover  s    --[[Xc.>.>%?[@CKK..01,,.C A T>dii::gEMMO
 A@s   5C
C)r   r7   r3   r<   r6   r4   )r>   r.   r6   r5   rO   )rb   r[   rD   r]   rE   
int | NonerF   zAdaptContext | Noner6   zRowFactory[Row] | Noner3   ztype[Cursor[Row]] | Nonerc   r   returnr   )r  r   )r{   ztype[BaseException] | Noner|   zBaseException | Noner}   zTracebackType | Noner  None)rb   r[   rc   r   r  r   )r  r  )r   r]   r  Cursor[Row])r   r]   r6   RowFactory[CursorRow]r  zCursor[CursorRow])
r   r[   r   r]   r   bool | Noner   r]   r  zServerCursor[Row])r   r[   r   r]   r6   r  r   r  r   r]   r  zServerCursor[CursorRow])r   r[   r   r]   r6   zRowFactory[Any] | Noner   r  r   r]   r  zCursor[Any] | ServerCursor[Any]r9   )
r   r   rd   zParams | Noner   r  r   r]   r  r  )rI   floatr  r  )NF)r   z
str | Noner   r]   r  zIterator[Transaction])rI   float | Noner   r  r  zGenerator[Notify, None, None])r  zIterator[Pipeline])rh   z	PQGen[RV]rK   r  r  r   )r   r]   r  r  )r   zIsolationLevel | Noner  r  )r   r  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;   classmethodrk   rp   r   rQ   rz   r
   r   r   rx   ru   r   r   r   r   r%   r   rT   r   r   r   r   r   r   r   r   r   r   r   r   r  r  __static_attributes____classcell__)r?   s   @r@   r1   r1   8   sy    J%%22  
 (,JsOY'G	2	2 %	2 	2  1 !()'+.23711 	1
 &1 %1 ,1 11 1 
1 1f, & %	
 
. 4 4 ',A A %  4I 	    
 "&   	 
      
    
 "&&& 	&
 +&  & & 
!& &   .2"&   	 
 ,       
) J !%*
  $** *
 * * 
*$*
,
 /3 4 /2 @ HM(AE	 * *.0&0;E0	&0d * *& =K (#7
(<
"6
#7
09;=
 
rB   r1   )Qr  
__future__r   loggingtimer   typesr   typingr   r   r   r	   r
   r   
contextlibr   rP   r   r   rU   r   abcr   r   r   r   r   r   r   _tpcr   rowsr   r   r   r   adaptr   _enumsr   _compatr   rb   r    r!   r"   r#   r7   r$   
generatorsr%   r   r&   r   r'   _capabilitiesr(   server_cursorr)   _connection_baser*   r+   r,   	threadingr-   pq.abcr.   rT   FormatTEXTr   TransactionStatusr  r   r  KeyboardInterruptr   	getLoggerrX   r1   rn   rB   r@   <module>r;     s    #    J J %    L L L  6 6  "  5 >    $  ' ' ? ? 	yy~~				  				$	$



&
& 			9	%g$ grB   