
    b?i0                     f    S SK Jr   " S S5      r " S S\5      r " S S\5      r " S S	\5      rg
)   )excc                   h    \ rS rSrSrS r\S 5       r\S 5       rS r	S r
S rS	 rS
 rS rS rSrg)Transaction   ak  Represent a database transaction in progress.

The Transaction object is procured by
calling the SAConnection.begin() method of
SAConnection:

    with (yield from engine) as conn:
        trans = yield from conn.begin()
        try:
            yield from conn.execute("insert into x (a, b) values (1, 2)")
        except Exception:
            yield from trans.rollback()
        else:
            yield from trans.commit()

The object provides .rollback() and .commit()
methods in order to control transaction boundaries.

See also:  SAConnection.begin(), SAConnection.begin_twophase(),
SAConnection.begin_nested().
c                 >    Xl         U=(       d    U U l        SU l        g )NT)_connection_parent
_is_active)self
connectionparents      [/var/www/html/livechat/backend/venv/lib/python3.13/site-packages/aiomysql/sa/transaction.py__init__Transaction.__init__   s    %~    c                     U R                   $ )z+Return ``True`` if a transaction is active.)r
   r   s    r   	is_activeTransaction.is_active"   s     r   c                     U R                   $ )z8Return transaction's connection (SAConnection instance).)r   r   s    r   r   Transaction.connection'   s     r   c                    #    U R                   R                  (       d  gU R                   U L a  U R                  5       I Sh  vN   gSU l        g N7f)a   Close this transaction.

If this transaction is the base transaction in a begin/commit
nesting, the transaction will rollback().  Otherwise, the
method returns.

This is used to cancel a Transaction without affecting the scope of
an enclosing transaction.
NF)r	   r
   rollbackr   s    r   closeTransaction.close,   s>      ||&&<<4--/!!#DO "s   ?AAAc                    #    U R                   R                  (       d  gU R                  5       I Sh  vN   SU l        g N7f)zRoll back this transaction.NF)r	   r
   _do_rollbackr   s    r   r   Transaction.rollback=   s3     ||&&!!! 	"s   0A?Ac                 T   #    U R                   R                  5       I S h  vN   g  N7fN)r	   r   r   s    r   r   Transaction._do_rollbackD   s     ll##%%%   (&(c                    #    U R                   R                  (       d  [        R                  " S5      eU R	                  5       I Sh  vN   SU l        g N7f)zCommit this transaction.This transaction is inactiveNF)r	   r
   r   InvalidRequestError
_do_commitr   s    r   commitTransaction.commitG   sB      ||&&))*HIIoo 	 s   AAAAc                    #    g 7fr     r   s    r   r&   Transaction._do_commitO   s     s   c                    #    U $ 7fr    r*   r   s    r   
__aenter__Transaction.__aenter__R   s
     s   c                    #    U(       a  U R                  5       I S h  vN   g U R                  (       a  U R                  5       I S h  vN   g g  N0 N7fr    )r   r
   r'   )r   exc_typeexc_valexc_tbs       r   	__aexit__Transaction.__aexit__U   s<     --/!!kkm##  " $s!   AA)AAAA)r   r
   r	   N)__name__
__module____qualname____firstlineno____doc__r   propertyr   r   r   r   r   r'   r&   r-   r3   __static_attributes__r*   r   r   r   r      sW    ,
      $" & $r   r   c                   4   ^  \ rS rSrU 4S jrS rS rSrU =r$ )RootTransaction]   c                 &   > [         TU ]  US 5        g r    superr   )r   r   	__class__s     r   r   RootTransaction.__init___   s    T*r   c                 T   #    U R                   R                  5       I S h  vN   g  N7fr    )r   _rollback_implr   s    r   r   RootTransaction._do_rollbackb   s     --///r"   c                 T   #    U R                   R                  5       I S h  vN   g  N7fr    )r   _commit_implr   s    r   r&   RootTransaction._do_commite   s     ++---r"   r*   )	r5   r6   r7   r8   r   r   r&   r;   __classcell__rB   s   @r   r=   r=   ]   s    +0. .r   r=   c                   <   ^  \ rS rSrSrSrU 4S jrS rS rSr	U =r
$ )NestedTransactioni   zRepresent a 'nested', or SAVEPOINT transaction.

A new NestedTransaction object may be procured
using the SAConnection.begin_nested() method.

The interface is the same as that of Transaction class.
Nc                 $   > [         TU ]  X5        g r    r@   )r   r   r   rB   s      r   r   NestedTransaction.__init__t   s    ,r   c                    #    U R                   c   S5       eU R                  (       a9  U R                  R                  U R                   U R                  5      I S h  vN   g g  N7fNzBroken transaction logic)
_savepointr
   r   _rollback_to_savepoint_implr	   r   s    r   r   NestedTransaction._do_rollbackw   sW     *F,FF*??"">>/ / / /   AA$A"A$c                    #    U R                   c   S5       eU R                  (       a9  U R                  R                  U R                   U R                  5      I S h  vN   g g  N7frR   )rS   r
   r   _release_savepoint_implr	   r   s    r   r&   NestedTransaction._do_commit}   sW     *F,FF*??""::/ / / /rV   r*   )r5   r6   r7   r8   r9   rS   r   r   r&   r;   rJ   rK   s   @r   rM   rM   i   s#     J-// /r   rM   c                   N   ^  \ rS rSrSrU 4S jr\S 5       rS rS r	S r
SrU =r$ )	TwoPhaseTransaction   zRepresent a two-phase transaction.

A new TwoPhaseTransaction object may be procured
using the SAConnection.begin_twophase() method.

The interface is the same as that of Transaction class
with the addition of the .prepare() method.
c                 @   > [         TU ]  US 5        SU l        X l        g )NF)rA   r   _is_prepared_xid)r   r   xidrB   s      r   r   TwoPhaseTransaction.__init__   s    T*!	r   c                     U R                   $ )z Returns twophase transaction id.)r_   r   s    r   r`   TwoPhaseTransaction.xid   s     yyr   c                    #    U R                   R                  (       d  [        R                  " S5      eU R                  R                  U R                  5      I Sh  vN   SU l        g N7f)zVPrepare this TwoPhaseTransaction.

After a PREPARE, the transaction can be committed.
r$   NT)r	   r   r   r%   r   _prepare_twophase_implr_   r^   r   s    r   prepareTwoPhaseTransaction.prepare   sR      ||%%))*HII55dii@@@  	As   AA+A)A+c                 |   #    U R                   R                  U R                  U R                  S9I S h  vN   g  N7fN)is_prepared)r   rollback_preparedr_   r^   r   s    r   r    TwoPhaseTransaction._do_rollback   s7     00II4#4#4 1 6 	6 	6   2<:<c                 |   #    U R                   R                  U R                  U R                  S9I S h  vN   g  N7fri   )r   commit_preparedr_   r^   r   s    r   r&   TwoPhaseTransaction._do_commit   s7     ..II4#4#4 / 6 	6 	6rm   )r^   r_   )r5   r6   r7   r8   r9   r   r:   r`   rf   r   r&   r;   rJ   rK   s   @r   r[   r[      s5    
  	!66 6r   r[   N) r   r   r=   rM   r[   r*   r   r   <module>rr      s;    T$ T$n	.k 	./ /6%6+ %6r   