
    +h                     ~    d Z ddlmZ ddlmZ ddlmZ i Z ej                  dd      d        Zd	 Z	 G d
 de
      Zy)zDBAPI proxy utility.

Provides transparent connection pooling on top of a Python DBAPI.

This is legacy SQLAlchemy functionality that is not typically used
today.

   )	QueuePool   )util)	threadingz1.3zYThe :func:`.pool.manage` function is deprecated, and will be removed in a future release.c           	      t    	 t         |    S # t        $ r# t         j                  | t        | fi |      cY S w xY w)aH  Return a proxy for a DB-API module that automatically
    pools connections.

    Given a DB-API 2.0 module and pool management parameters, returns
    a proxy for the module that will automatically pool connections,
    creating new connection pools for each distinct set of connection
    arguments sent to the decorated module's connect() function.

    :param module: a DB-API 2.0 database module

    :param poolclass: the class used by the pool module to provide
      pooling.  Defaults to :class:`.QueuePool`.

    :param \**params: will be passed through to *poolclass*

    )proxiesKeyError
setdefault_DBProxy)moduleparamss     N/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/pool/dbapi_proxy.pymanager      s@    ,Fv F!!&(6*DV*DEEFs    )77c                  ~    t         j                         D ]  } | j                           t         j                          y)zYRemove all current DB-API 2.0 managers.

    All pools and connections are disposed.
    N)r   valuescloseclear)managers    r   clear_managersr   5   s,     >># MMO    c                   D    e Zd ZdZefdZd Zd Zd Zd Z	d Z
d Zd	 Zy
)r   a	  Layers connection pooling behavior on top of a standard DB-API module.

    Proxies a DB-API 2.0 connect() call to a connection pool keyed to the
    specific connect parameters. Other functions and attributes are delegated
    to the underlying DB-API module.
    c                 n    || _         || _        || _        i | _        t	        j
                         | _        y)zInitializes a new proxy.

        module
          a DB-API 2.0 module

        poolclass
          a Pool class, defaulting to QueuePool

        Other parameters are sent to the Pool object's constructor.

        N)r   kw	poolclasspoolsr   Lock_create_pool_mutex)selfr   r   r   s       r   __init__z_DBProxy.__init__I   s/     "
"+.."2r   c                 R    t        | j                        D ]  }| j                  |=  y N)listr   r   keys     r   r   z_DBProxy.close\   s%    

# 	 C

3	 r   c                 $    | j                          y r!   )r   )r   s    r   __del__z_DBProxy.__del__`   s    

r   c                 .    t        | j                  |      S r!   )getattrr   r#   s     r   __getattr__z_DBProxy.__getattr__c   s    t{{C((r   c                       j                   i }	  j                  |   S # t        $ r  j                  5  | j                  vrPj	                  dd          j
                   fdfi  j                  }| j                  |<   |cd d d        cY S  j                  |   cd d d        cY S # 1 sw Y   Y y xY ww xY w)Nsa_pool_keyc                  <     j                   j                   i S r!   )r   connect)argsr   r   s   r   <lambda>z#_DBProxy.get_pool.<locals>.<lambda>o   s     3 3 3T @R @ r   )
_serializer   r	   r   popr   r   )r   r.   r   r$   pools   ```  r   get_poolz_DBProxy.get_poolf   s    doot*r*	+::c?" 
	+(( 	+djj(FF=$/)4>>@DHGGD '+DJJsO	+ 	+  ::c?	+ 	+ 	+
	+s3   & CAB4
CB4(
C4B>	9C>Cc                 B     | j                   |i |j                         S )a,  Activate a connection to the database.

        Connect to the database using this DBProxy's module and the given
        connect arguments.  If the arguments match an existing pool, the
        connection will be returned from the pool's current thread-local
        connection instance, or if there is no thread-local connection
        instance it will be checked out from the set of pooled connections.

        If the pool has no available connections and allows new connections
        to be created, a new database connection will be made.

        )r3   r-   )r   r.   r   s      r   r-   z_DBProxy.connectv   s#     t}}d)b)1133r   c                 b     | j                   |i |}	 | j                  |= y# t        $ r Y yw xY w)z;Dispose the pool referenced by the given connect arguments.N)r0   r   r	   )r   r.   r   r$   s       r   disposez_DBProxy.dispose   s;     doot*r*	

3 		s   " 	..c           	          d|v r|d   S t        t        |      t        |      D cg c]	  }|||   f c}z         S c c}w )Nr+   )tupler"   sorted)r   r.   r   ks       r   r0   z_DBProxy._serialize   sC    Bm$$T$Zvbz"B!Ar!u:"BBCC"Bs   =
N)__name__
__module____qualname____doc__r   r   r   r&   r)   r3   r-   r6   r0    r   r   r   r   @   s5     *3 3& )+ 4 Dr   r   N)r>   implr    r   r   r   
deprecatedr   r   objectr   r?   r   r   <module>rD      sX      
 	#
F
F.SDv SDr   