o
    FDi                     @   sX   d dl mZmZ d dlmZ erd dlmZ d dlmZ G dd dZ	G dd dZ
d	S )
    )TYPE_CHECKINGOptional)	QueryInfo)
Connection)
ServerInfoc                   @   sb   e Zd Zdd Zedd Zejdd Zedd Zejdd Zed	d
 Zejdd
 ZdS )Contextc                 C   s   d | _ i | _i | _d S N)_server_info	_settings_client_settingsself r   M/var/www/Datamplify/venv/lib/python3.10/site-packages/asynch/proto/context.py__init__   s   
zContext.__init__c                 C   s   | j S r   r	   r   r   r   r   server_info   s   zContext.server_infoc                 C   s
   || _ d S r   r   r   valuer   r   r   r         
c                 C   
   | j  S r   )r
   copyr   r   r   r   settings   r   zContext.settingsc                 C      |  | _d S r   )r   r
   r   r   r   r   r         c                 C   r   r   )r   r   r   r   r   r   client_settings    r   zContext.client_settingsc                 C   r   r   )r   r   r   r   r   r   r   $   r   N)	__name__
__module____qualname__r   propertyr   setterr   r   r   r   r   r   r   
   s    




r   c                   @   s&   e Zd Zd
ddZdd Zdd Zd	S )ExecuteContext
connectionr   c                 C   s"   || _ || _|| _| j| d S r   )_queryr
   _connectionmake_query_settings)r   r"   queryr   r   r   r   r   *   s   zExecuteContext.__init__c              	      sN   z| j  I d H  t| j j| j _W d S  ttfy&   | j  I d H   w r   )r$   force_connectr   reader
last_query	ExceptionKeyboardInterrupt
disconnectr   r   r   r   
__aenter__0   s   zExecuteContext.__aenter__c                    s:   |rt |ttfr| j I d H  || j| j d S r   )
issubclassr*   r+   r$   r,   track_current_databaser#   )r   exc_typeexc_valexc_tbr   r   r   	__aexit__8   s   zExecuteContext.__aexit__N)r"   r   )r   r   r   r   r-   r3   r   r   r   r   r!   )   s    
r!   N)typingr   r   asynch.proto.resultr   asynch.proto.connectionr   asynch.proto.csr   r   r!   r   r   r   r   <module>   s    