
    b?i/:                         S SK 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
  SSKJrJrJrJr  S	S
KJrJr  S r " S S5      rS rg)    N)ClauseElement)
UpdateBase)
DDLElement   )exc)create_result_proxy)RootTransactionTransactionNestedTransactionTwoPhaseTransaction   )_TransactionContextManager_SAConnectionContextManagerc                     U $ N )ks    Z/var/www/html/livechat/backend/venv/lib/python3.13/site-packages/aiomysql/sa/connection.pynoopr      s    H    c                       \ rS rSrS S jrS 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 S jrS rS rS S jrS rS rSS.S jrSS.S jr\
S 5       rS rS rS rSrg)!SAConnection   Nc                     Xl         S U l        SU l        [        R                  " 5       U l        X l        UR                  U l        X0l	        g )Nr   )
_connection_transaction_savepoint_seqweakrefWeakSet_weak_results_enginedialect_dialect_compiled_cache)self
connectionenginecompiled_caches       r   __init__SAConnection.__init__   s=    % $__.-r   c                 D    U R                   " U/UQ70 UD6n[        U5      $ )aX  Executes a SQL query with optional parameters.

query - a SQL query string or any sqlalchemy expression.

*multiparams/**params - represent bound parameter values to be
used in the execution.  Typically, the format is a dictionary
passed to *multiparams:

    await conn.execute(
        table.insert(),
        {"id":1, "value":"v1"},
    )

...or individual key/values interpreted by **params::

    await conn.execute(
        table.insert(), id=1, value="v1"
    )

In the case that a plain SQL string is passed, a tuple or
individual values in *multiparams may be passed::

    await conn.execute(
        "INSERT INTO table (id, value) VALUES (%d, %s)",
        (1, "v1")
    )

    await conn.execute(
        "INSERT INTO table (id, value) VALUES (%s, %s)",
        1, "v1"
    )

Returns ResultProxy instance with results of SQL query
execution.

)_executer   )r%   querymultiparamsparamscoros        r   executeSAConnection.execute   s(    J }}U;[;F;*400r   c                    U(       ax  [        U[        [        45      (       a]  U(       a@  [        UR                  R
                  U5       VVs0 s H  u  pVUR                  U_M     nnnO[        R                  " S5      eUR                  U5      nUR                  nU V	s0 s H!  n	XR                  U	[        5      " Xy   5      _M#     sn	/n
U R                  R                  U
5      nUS   $ s  snnf s  sn	f )z
handle params
z=Don't mix sqlalchemy SELECT clause with positional parametersr   )
isinstancelisttupleziptableckeyr   ArgumentErrorconstruct_params_bind_processorsgetr   r#   execute_sequence_format)r%   r-   dpcompiled	is_updater9   pvalcompiled_params
processorsr:   r/   post_processed_paramss               r   _base_paramsSAConnection._base_paramsG   s     *R$//14U[[]]B1GH1GgaaeeTk1GH''! 
 #33B7..
 '
& T*?+?@@&
  !% E Ef M$Q'' I
s   C-!(C3c           	        #    Sn[        U[        5      (       a  UR                  X5      I Sh  vN   O[        U[        5      (       a  [        R
                  " S5      e[        U[        5      (       a  UR                  U R                  S9n/ n[        U[        5      nU H&  nUR                  U R                  UUUU5      5        M(     UR                  [        U5      U5      I Sh  vN   UR                  nO[        R
                  " S5      e[        U UU R                  U5      I Sh  vN n	U R                  R                  U	5        U	$  GN  Ng N&7f)z
executemany
N=Don't mix sqlalchemy DDL clause and execution with parametersr"   Lsql statement should be str or SQLAlchemy data selection/modification clause)r4   strexecutemanyr   r   r;   r   compiler#   r   appendrG   _result_columnsr   r    add)
r%   r-   dpscursor
result_maprA   r/   rB   r@   rets
             r   _executemanySAConnection._executemany]   sA     
eS!!$$U000z**##4  }--}}T]]};HF"5*5I%% !	  $$S]F;;;!11J##0 
 (MM	
 
 	s#
E 1& <
s5   ,EEB:E)E*AE,E-"EEEc           	        #    U R                   R                  5       I S h  vN n[        X#5      n[        U5      S:  a  U R	                  XU5      I S h  vN $ U(       a  US   nS n[        U[        5      (       a$  UR                  X=(       d    S 5      I S h  vN   GO[        U[        5      (       GaT  U R                  b  UnU R                  R                  U5      nU(       dr  UR                  U R                  S9nU(       a,  UR                  5       UR                  R                  5       :X  d  U(       d  UR                  (       d  XR                  U'   OUR                  U R                  S9n[        U[        5      (       d/  U R!                  UUU[        U["        5      5      n	UR$                  nO/U(       a  [&        R(                  " S5      eUR+                  5       n	S nUR                  [        U5      U	5      I S h  vN   O[&        R(                  " S5      e[-        XU R                  U5      I S h  vN n
U R.                  R1                  U
5        U
$  GN< GN GN N` N,7f)Nr   r   rK   rJ   rL   )r   rT   _distill_paramslenrW   r4   rM   r1   r   r$   r>   rO   r#   keysr/   r   rG   r   rQ   r   r;   r<   r   r    rR   )r%   r-   r.   r/   rT   r@   rU   r:   rA   rF   rV   s              r   r,   SAConnection._execute   s    ''..00[1r7Q;**5f===AB
eS!!..
d333}--##///33C8$}}T]]}CHbggi8??+?+?+AA$&(//4<,,S1 ===?eZ00(,(9(9uj1	)% &55
++ -L M M(0(A(A(C%!
..X0EFFF## %D E E ($--
 
 	s#
_ 1 > 48 G
sY   I)I3I)IAI)I"E*I)I%5I):I';"I)I)"I)%I)'I)c                 ~   #    U R                   " U/UQ70 UD6I Sh  vN nUR                  5       I Sh  vN $  N N7f)z0Executes a SQL query and returns a scalar value.N)r1   scalar)r%   r-   r.   r/   ress        r   r_   SAConnection.scalar   s8     LL????jjl"# @"s   =9=;==c                 X    U R                   SL =(       d    U R                   R                  $ )zAThe readonly property that returns True if connections is closed.N)r   closedr%   s    r   rc   SAConnection.closed   s&     4'B4+;+;+B+BBr   c                     U R                   $ r   )r   rd   s    r   r&   SAConnection.connection   s    r   c                 8    U R                  5       n[        U5      $ )a  Begin a transaction and return a transaction handle.

The returned object is an instance of Transaction.  This
object represents the "scope" of the transaction, which
completes when either the .rollback or .commit method is
called.

Nested calls to .begin on the same SAConnection instance will
return new Transaction objects that represent an emulated
transaction within the scope of the enclosing transaction,
that is::

    trans = await conn.begin()   # outermost transaction
    trans2 = await conn.begin()  # "nested"
    await trans2.commit()        # does nothing
    await trans.commit()         # actually commits

Calls to .commit only have an effect when invoked via the
outermost Transaction object, though the .rollback method of
any of the Transaction objects will roll back the transaction.

See also:
  .begin_nested - use a SAVEPOINT
  .begin_twophase - use a two phase/XA transaction

)_beginr   )r%   r0   s     r   beginSAConnection.begin   s    6 {{})$//r   c                    #    U R                   c4  [        U 5      U l         U R                  5       I S h  vN   U R                   $ [        X R                   5      $  N%7fr   )r   r	   _begin_implr
   rd   s    r   ri   SAConnection._begin   sR     $ / 5D""$$$$$$t%6%677 %s   1AA&Ac                    #    U R                   R                  5       I S h  vN n UR                  S5      I S h  vN   UR                  5       I S h  vN   g  N7 N N	! UR                  5       I S h  vN    f = f7f)NBEGIN)r   rT   r1   closer%   curs     r   rm   SAConnection._begin_impl   s\     $$++--	++g&&&))+	 .&#))+sS   A<AA<A AA A<AA<A A<A92A53A99A<c                   #    U R                   R                  5       I S h  vN n UR                  S5      I S h  vN   UR                  5       I S h  vN   S U l        g  N> N& N! UR                  5       I S h  vN    S U l        f = f7f)NCOMMITr   rT   r1   rq   r   rr   s     r   _commit_implSAConnection._commit_impl   sl     $$++--	%++h'''))+ $D .'#))+ $DS   B
AB
A% A!A% B
A#B
!A% #B
%B9A<:BB
c                   #    U R                   R                  5       I S h  vN n UR                  S5      I S h  vN   UR                  5       I S h  vN   S U l        g  N> N& N! UR                  5       I S h  vN    S U l        f = f7f)NROLLBACKrw   rr   s     r   _rollback_implSAConnection._rollback_impl   sl     $$++--	%++j)))))+ $D .)#))+ $Drz   c                 .  #    U R                   c4  [        U 5      U l         U R                  5       I Sh  vN   U R                   $ [        X R                   5      U l         U R	                  5       I Sh  vN U R                   l        U R                   $  N] N!7f)a  Begin a nested transaction and return a transaction handle.

The returned object is an instance of :class:`.NestedTransaction`.

Nested transactions require SAVEPOINT support in the
underlying database.  Any transaction in the hierarchy may
.commit() and .rollback(), however the outermost transaction
still controls the overall .commit() or .rollback() of the
transaction of a whole.
N)r   r	   rm   r   _savepoint_impl
_savepointrd   s    r   begin_nestedSAConnection.begin_nested  s      $ / 5D""$$$     !2$8I8I JD151E1E1G+GD(   	 % ,Hs!   1BB=B1B2 BBc                 L  #    U =R                   S-  sl         SU R                   -  nU R                  R                  5       I S h  vN n UR                  SU-   5      I S h  vN   UUR	                  5       I S h  vN   $  N; N  N	! UR	                  5       I S h  vN    f = f7f)Nr   zaiomysql_sa_savepoint_%sz
SAVEPOINT )r   r   rT   r1   rq   )r%   namers   s      r   r   SAConnection._savepoint_impl  s     q )D,?,??$$++--	++lT1222))+ .2 #))+sZ   AB$B B$
B !B"B 'B$:B;B$B B$B!BB!!B$c                   #    U R                   R                  5       I S h  vN n UR                  SU-   5      I S h  vN   UR                  5       I S h  vN   X l        g  N@ N% N! UR                  5       I S h  vN    f = f7f)NzROLLBACK TO SAVEPOINT rw   r%   r   parentrs   s       r   _rollback_to_savepoint_impl(SAConnection._rollback_to_savepoint_impl"  sh     $$++--	++6=>>>))+" .>#))+T   BA!BA' A#A' BA%B#A' %B'B;A><BBc                   #    U R                   R                  5       I S h  vN n UR                  SU-   5      I S h  vN   UR                  5       I S h  vN   X l        g  N@ N% N! UR                  5       I S h  vN    f = f7f)NzRELEASE SAVEPOINT rw   r   s       r   _release_savepoint_impl$SAConnection._release_savepoint_impl*  sh     $$++--	++2T9:::))+" .:#))+r   c                    #    U R                   b  [        R                  " S5      eUc  U R                  R	                  5       n[        X5      U l         U R                  SU5      I Sh  vN   U R                   $  N7f)aG  Begin a two-phase or XA transaction and return a transaction
handle.

The returned object is an instance of
TwoPhaseTransaction, which in addition to the
methods provided by Transaction, also provides a
TwoPhaseTransaction.prepare() method.

xid - the two phase transaction id.  If not supplied, a
random id will be generated.
NzOCannot start a two phase transaction when a transaction is already in progress.zXA START %s)r   r   InvalidRequestErrorr#   
create_xidr   r1   r%   xids     r   begin_twophaseSAConnection.begin_twophase2  sv      ())*+ + ;--**,C/:ll=#...    	/s   A&A;(A9)A;c                    #    U R                  SU-  5      I S h  vN   U R                  SU-  5      I S h  vN   g  N! N7f)NXA END '%s'zXA PREPARE '%s'r1   r   s     r   _prepare_twophase_impl#SAConnection._prepare_twophase_implI  s<     ll=3.///ll,s2333 	03s   A <A >A A c                 t   #    U R                  S5      I Sh  vN nU Vs/ s H  o"S   PM	     sn$  Ns  snf 7f)z3Return a list of prepared twophase transaction ids.zXA RECOVER;Nr   r   )r%   resultrows      r   recover_twophaseSAConnection.recover_twophaseM  s5     ||M22"()&3A&)) 3)s   818388T)is_preparedc                   #    U(       d  U R                  SU-  5      I Sh  vN   U R                  SU-  5      I Sh  vN   g N! N7f)z'Rollback prepared twophase transaction.r   NzXA ROLLBACK '%s'r   r%   r   r   s      r   rollback_preparedSAConnection.rollback_preparedR  s?     ,,}s2333ll-3444 44   AAAAAAc                   #    U(       d  U R                  SU-  5      I Sh  vN   U R                  SU-  5      I Sh  vN   g N! N7f)z%Commit prepared twophase transaction.r   NzXA COMMIT '%s'r   r   s      r   commit_preparedSAConnection.commit_preparedX  s?     ,,}s2333ll+c1222 42r   c                 X    U R                   SL=(       a    U R                   R                  $ )z,Return True if a transaction is in progress.N)r   	is_activerd   s    r   in_transactionSAConnection.in_transaction^  s&       ,L1B1B1L1LLr   c                    #    U R                   c  gU R                  b)  U R                  R                  5       I Sh  vN   SU l        U R                  R	                  U 5        SU l         SU l        g N57f)a  Close this SAConnection.

This results in a release of the underlying database
resources, that is, the underlying connection referenced
internally. The underlying connection is typically restored
back to the connection-holding Pool referenced by the Engine
that produced this SAConnection. Any transactional state
present on the underlying connection is also unconditionally
released via calling Transaction.rollback() method.

After .close() is called, the SAConnection is permanently in a
closed state, and will allow no further operations.
N)r   r   rollbackr!   releaserd   s    r   rq   SAConnection.closec  sj      #(##,,... $D 	T" /s   9A3A16A3c                    #    U $ 7fr   r   rd   s    r   
__aenter__SAConnection.__aenter__}  s
     s   c                 @   #    U R                  5       I S h  vN   g  N7fr   )rq   )r%   exc_typeexc_valexc_tbs       r   	__aexit__SAConnection.__aexit__  s     jjls   )r$   r   r#   r!   r   r   r    r   ) __name__
__module____qualname____firstlineno__r)   r1   rG   rW   r,   r_   propertyrc   r&   rj   ri   rm   rx   r}   r   r   r   r   r   r   r   r   r   r   rq   r   r   __static_attributes__r   r   r   r   r      s    .&1P(,(T0d$
 C C    0<8%%!&	##!.4*
 ;? 5 9= 3 M M4r   r   c                 x   U (       d  U(       a  U/$ / $ [        U 5      S:X  al  U S   n[        U[        [        45      (       a4  U(       a(  [	        US   S5      (       a  [	        US   S5      (       d  U$ U/$ [	        US5      (       a  U/$ U//$ [	        U S   S5      (       a  [	        U S   S5      (       d  U $ U /$ )zGiven arguments from the calling form *multiparams, **params,
return a list of bind parameter structures, usually a list of
dictionaries.

In the case of 'raw' execution which accepts positional parameters,
it may be a list of tuples or lists.

r   r   __iter__stripr\   )r[   r4   r5   r6   hasattr)r.   r/   zeros      r   rZ   rZ     s     8OI	[	Q	1~dT5M**747J77Q11  vT6""6M F8OKNJ//KNG44= r   )r   sqlalchemy.sqlr   sqlalchemy.sql.dmlr   sqlalchemy.sql.ddlr    r   r   r   transactionr	   r
   r   r   utilsr   r   r   r   rZ   r   r   r   <module>r      s?     ( ) )  'B B Km m`%!r   