
    e0W                       d Z ddlmZ ddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	l
mZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  erddlm!Z! ddl"m#Z#  ej$        d          Z% G d dej&                  Z' G d de          Z( G d  d!e          Z) G d" d#e          Z* G d$ d%ej        j+                  Z, G d& d'ej        j-                  Z. G d( d)e          Z/ G d* d+e          Z0 G d, d-ej1                  Z2 G d. d/ej3                  Z4 G d0 d1ej5                  Z6 G d2 d3ej7                  Z8 G d4 d5ej9                  Z: G d6 d7ej;                  Z< G d8 d9ej=                  Z> G d: d;ej?                  Z@ G d< d=e	jA                  ZB G d> d?e	jC                  ZD G d@ dAe          ZE G dB dCe          ZF G dD dEe          ZGdF ZH G dG dHe          ZI G dI dJ          ZJ G dK dLeJ          ZK G dM dNe          ZL G dO dPeL          ZM G dQ dR          ZN G dS dTeI          ZOeIZPeOZQdS )UaR  
.. dialect:: postgresql+psycopg
    :name: psycopg (a.k.a. psycopg 3)
    :dbapi: psycopg
    :connectstring: postgresql+psycopg://user:password@host:port/dbname[?key=value&key=value...]
    :url: https://pypi.org/project/psycopg/

``psycopg`` is the package and module name for version 3 of the ``psycopg``
database driver, formerly known as ``psycopg2``.  This driver is different
enough from its ``psycopg2`` predecessor that SQLAlchemy supports it
via a totally separate dialect; support for ``psycopg2`` is expected to remain
for as long as that package continues to function for modern Python versions,
and also remains the default dialect for the ``postgresql://`` dialect
series.

The SQLAlchemy ``psycopg`` dialect provides both a sync and an async
implementation under the same dialect name. The proper version is
selected depending on how the engine is created:

* calling :func:`_sa.create_engine` with ``postgresql+psycopg://...`` will
  automatically select the sync version, e.g.::

    from sqlalchemy import create_engine
    sync_engine = create_engine("postgresql+psycopg://scott:tiger@localhost/test")

* calling :func:`_asyncio.create_async_engine` with
  ``postgresql+psycopg://...`` will automatically select the async version,
  e.g.::

    from sqlalchemy.ext.asyncio import create_async_engine
    asyncio_engine = create_async_engine("postgresql+psycopg://scott:tiger@localhost/test")

The asyncio version of the dialect may also be specified explicitly using the
``psycopg_async`` suffix, as::

    from sqlalchemy.ext.asyncio import create_async_engine
    asyncio_engine = create_async_engine("postgresql+psycopg_async://scott:tiger@localhost/test")

.. seealso::

    :ref:`postgresql_psycopg2` - The SQLAlchemy ``psycopg``
    dialect shares most of its behavior with the ``psycopg2`` dialect.
    Further documentation is available there.

    )annotationsN)cast)TYPE_CHECKING   )ranges)_PGDialect_common_psycopg)"_PGExecutionContext_common_psycopg)INTERVAL)
PGCompiler)PGIdentifierPreparer)	REGCONFIG)JSON)JSONB)JSONPathType)CITEXT   )pool)util)AdaptedConnection)sqltypes)await_fallback)
await_only)Iterable)AsyncConnectionzsqlalchemy.dialects.postgresqlc                      e Zd ZdZdS )	_PGStringTN__name__
__module____qualname__render_bind_cast     Flib/python3.11/site-packages/sqlalchemy/dialects/postgresql/psycopg.pyr   r   W           r#   r   c                      e Zd ZdZdS )_PGREGCONFIGTNr   r"   r#   r$   r'   r'   [   r%   r#   r'   c                      e Zd ZdZd Zd ZdS )_PGJSONTc                8    |                      d |j                  S N)_make_bind_processor_psycopg_Jsonselfdialects     r$   bind_processorz_PGJSON.bind_processorb   s    ((w/DEEEr#   c                    d S r+   r"   r/   r0   coltypes      r$   result_processorz_PGJSON.result_processore       tr#   Nr   r   r    r!   r1   r5   r"   r#   r$   r)   r)   _   s;        F F F    r#   r)   c                      e Zd ZdZd Zd ZdS )_PGJSONBTc                8    |                      d |j                  S r+   )r,   _psycopg_Jsonbr.   s     r$   r1   z_PGJSONB.bind_processorl   s    ((w/EFFFr#   c                    d S r+   r"   r3   s      r$   r5   z_PGJSONB.result_processoro   r6   r#   Nr7   r"   r#   r$   r9   r9   i   s;        G G G    r#   r9   c                      e Zd ZdZdZdS )_PGJSONIntIndexTypejson_int_indexTNr   r   r    __visit_name__r!   r"   r#   r$   r>   r>   s           %Nr#   r>   c                      e Zd ZdZdZdS )_PGJSONStrIndexTypejson_str_indexTNr@   r"   r#   r$   rD   rD   y   rB   r#   rD   c                      e Zd ZdS )_PGJSONPathTypeNr   r   r    r"   r#   r$   rG   rG              Dr#   rG   c                      e Zd ZdZdS )_PGIntervalTNr   r"   r#   r$   rK   rK      r%   r#   rK   c                      e Zd ZdZdS )_PGTimeStampTNr   r"   r#   r$   rM   rM      r%   r#   rM   c                      e Zd ZdZdS )_PGDateTNr   r"   r#   r$   rO   rO      r%   r#   rO   c                      e Zd ZdZdS )_PGTimeTNr   r"   r#   r$   rQ   rQ      r%   r#   rQ   c                      e Zd ZdZdS )
_PGIntegerTNr   r"   r#   r$   rS   rS      r%   r#   rS   c                      e Zd ZdZdS )_PGSmallIntegerTNr   r"   r#   r$   rU   rU      r%   r#   rU   c                      e Zd ZdZdS )_PGNullTypeTNr   r"   r#   r$   rW   rW      r%   r#   rW   c                      e Zd ZdZdS )_PGBigIntegerTNr   r"   r#   r$   rY   rY      r%   r#   rY   c                      e Zd ZdZdS )
_PGBooleanTNr   r"   r#   r$   r[   r[      r%   r#   r[   c                      e Zd Zd Zd ZdS )_PsycopgRangec                F    t          t          |          j        fd}|S )Nc                    t          | t          j                  r" | j        | j        | j        | j                  } | S r+   )
isinstancer   Rangelowerupperboundsempty)valuepsycopg_Ranges    r$   to_rangez._PsycopgRange.bind_processor.<locals>.to_range   s@    %.. %KelEK  Lr#   )r   PGDialect_psycopg_psycopg_Range)r/   r0   rh   rg   s      @r$   r1   z_PsycopgRange.bind_processor   s6    .88G	 	 	 	 	 r#   c                    d }|S )Nc                v    | 6t          j        | j        | j        | j        r| j        nd| j                   } | S )N[)rd   re   r   ra   _lower_upper_boundsrf   s    r$   rh   z0_PsycopgRange.result_processor.<locals>.to_range   sG     LL,1MC5==t#m+	   Lr#   r"   r/   r0   r4   rh   s       r$   r5   z_PsycopgRange.result_processor   s    	 	 	 r#   Nr   r   r    r1   r5   r"   r#   r$   r]   r]      s2        
 
 
    r#   r]   c                      e Zd Zd Zd ZdS )_PsycopgMultiRangec                    t          t          |          j        t          t          |          j        t	          d           fd}|S )Nc                    t          | t          f          r| S  fdt          d|           D                       S )Nc                T    g | ]$} |j         |j        |j        |j                  %S r"   )rb   rc   rd   re   ).0elementrg   s     r$   
<listcomp>zG_PsycopgMultiRange.bind_processor.<locals>.to_range.<locals>.<listcomp>   sK          "M	   r#   zIterable[ranges.Range])r`   strr   )rf   NoneTypepsycopg_Multirangerg   s    r$   rh   z3_PsycopgMultiRange.bind_processor.<locals>.to_range   sj    %#x1C!DEE %%    $((@%#H#H  
 
 
r#   )r   ri   rj   _psycopg_Multirangetype)r/   r0   rh   r   r   rg   s      @@@r$   r1   z!_PsycopgMultiRange.bind_processor   si    .88G!w
 

 	 ::	 	 	 	 	 	 	  r#   c                    d }|S )Nc                "    | d | D             } | S )Nc                z    g | ]8}t          j        |j        |j        |j        r|j        nd |j                   9S )rm   rn   ro   )r{   elems     r$   r}   zI_PsycopgMultiRange.result_processor.<locals>.to_range.<locals>.<listcomp>   s]         L/3|Et||"&,.	    r#   r"   rs   s    r$   rh   z5_PsycopgMultiRange.result_processor.<locals>.to_range   s/       !&   Lr#   r"   rt   s       r$   r5   z#_PsycopgMultiRange.result_processor   s    	 	 	 r#   Nru   r"   r#   r$   rw   rw      s2          4    r#   rw   c                      e Zd ZdS )PGExecutionContext_psycopgNrH   r"   r#   r$   r   r      rI   r#   r   c                      e Zd ZdS )PGCompiler_psycopgNrH   r"   r#   r$   r   r      rI   r#   r   c                      e Zd ZdS )PGIdentifierPreparer_psycopgNrH   r"   r#   r$   r   r      rI   r#   r   c                R    t                               d| j        | j                   d S )Nz%s: %s)loggerinfoseveritymessage_primary)
diagnostics    r$   _log_noticesr      s$    
KK*-z/IJJJJJr#   c                      e Zd ZdZdZdZdZdZeZ	e
ZeZdZdZdZ ej        ej        i ej        eeeeeeeej        eeeej        j        e ej        j!        e"ej        j#        e$ej%        e&e'e&ej(        e)ej*        e+ej,        e-ej.        e/ej0        e1ej2        e3e4j5        e6e4j7        e8i          Z fdZ9 fdZ:d Z; fd	Z<e=d
             Z>e=d             Z?ej@        d             ZAej@        d             ZBej@        d             ZCej@        d             ZDej@        d             ZEej@        d             ZFd ZG fdZHd ZId ZJd ZKd ZLd ZMddZN	 ddZO	 ddZPej@        d             ZQ xZRS ) ri   psycopgTpyformat)r   r   Nc                    t                      j        di | | j        r%t          j        d| j        j                  }|r3t          d |                    ddd          D                       | _        | j        dk     rt          d          dd	l
m}  || j        j                  x| _        }| j        d
u rNdd l}|                    d|j        j        j                   |                    d|j        j        j                   | j        rddlm}  || j        |           | j        rddlm}  || j        |           d S d S d S )Nz(\d+)\.(\d+)(?:\.(\d+))?c              3  8   K   | ]}|t          |          V  d S r+   )int)r{   xs     r$   	<genexpr>z-PGDialect_psycopg.__init__.<locals>.<genexpr>.  s1       - - CFF- -r#   r      r   )r   r   r   z,psycopg version 3.0.2 or higher is required.r   )AdaptersMapFinetcidr)set_json_loads)set_json_dumpsr"   )super__init__dbapirematch__version__tuplegrouppsycopg_versionImportErrorpsycopg.adaptr   adapters_psycopg_adapters_map_native_inet_typespsycopg.types.stringregister_loadertypesstring
TextLoader_json_deserializerpsycopg.types.jsonr   _json_serializerr   )	r/   kwargsmr   adapters_mapr   r   r   	__class__s	           r$   r   zPGDialect_psycopg.__init__(  s   ""6""": $	D4dj6LMMA ', - -$%GGAq!$4$4- - - ( ($ #i//!B   2111118C
#9 9 D& &%//++++,,GM0;   ,,GM0;   & F======t6EEE$ D======t4lCCCCCI$	D $	DBD Dr#   c                    t                                          |          \  }}| j        r
| j        |d<   | j        
| j        |d<   ||fS )Ncontextclient_encoding)r   create_connect_argsr   r   )r/   urlcargscparamsr   s       r$   r   z%PGDialect_psycopg.create_connect_argsQ  sW    44S99w% 	<!%!;GI+)-)=G%&g~r#   c                N    ddl m} |                    |j        j        |          S Nr   )TypeInfo)psycopg.typesr   fetch
connectiondriver_connection)r/   r   namer   s       r$   _type_info_fetchz"PGDialect_psycopg._type_info_fetch[  s.    ******~~j3EtLLLr#   c                   t                                          |           | j        sd| _        | j        rP|                     |d          }|d u| _        | j        r,ddlm}  ||| j	                    |||j
                   d S d S d S )NFhstorer   )register_hstore)r   
initializeinsert_returninginsert_executemany_returninguse_native_hstorer   _has_native_hstorepsycopg.types.hstorer   r   r   )r/   r   r   r   r   s       r$   r   zPGDialect_psycopg.initialize`  s    :&&& $ 	605D-
 ! 	=((X>>D&*$&6D#& =@@@@@@  d&@AAA  j&;<<<<<	= 	== =r#   c                    dd l }|S Nr   )r   )clsr   s     r$   import_dbapizPGDialect_psycopg.import_dbapix  s    r#   c                    t           S r+   )PGDialectAsync_psycopg)r   r   s     r$   get_async_dialect_clsz'PGDialect_psycopg.get_async_dialect_cls~  s    %%r#   c                    | j         j        j        | j         j        j        | j         j        j        | j         j        j        dS )N)zREAD COMMITTEDzREAD UNCOMMITTEDzREPEATABLE READSERIALIZABLE)r   IsolationLevelREAD_COMMITTEDREAD_UNCOMMITTEDREPEATABLE_READr   r/   s    r$   _isolation_lookupz#PGDialect_psycopg._isolation_lookup  s?     #j7F $
 9 J#z8H J5B	
 
 	
r#   c                    ddl m} |j        S Nr   )json)r   r   Jsonr/   r   s     r$   r-   zPGDialect_psycopg._psycopg_Json  s    &&&&&&yr#   c                    ddl m} |j        S r   )r   r   Jsonbr   s     r$   r;   z PGDialect_psycopg._psycopg_Jsonb  s    &&&&&&zr#   c                    ddl m} |S )Nr   )TransactionStatus)
psycopg.pqr   )r/   r   s     r$   _psycopg_TransactionStatusz,PGDialect_psycopg._psycopg_TransactionStatus  s    000000  r#   c                    ddl m} |S )Nr   )ra   )psycopg.types.rangera   )r/   ra   s     r$   rj   z PGDialect_psycopg._psycopg_Range  s    ------r#   c                    ddl m} |S )Nr   )
Multirange)psycopg.types.multiranger   )r/   r   s     r$   r   z%PGDialect_psycopg._psycopg_Multirange  s    777777r#   c                "    ||_         ||_        d S r+   
autocommitisolation_levelr/   r   r   r   s       r$   _do_isolation_levelz%PGDialect_psycopg._do_isolation_level  s     *
%4
"""r#   c                    |j         j        }t                                          |          }|| j        j        k    r|                                 |S r+   )r   transaction_statusr   get_isolation_levelr   IDLErollback)r/   dbapi_connectionstatus_beforerf   r   s       r$   r   z%PGDialect_psycopg.get_isolation_level  sP    (-@++,<== D;@@@%%'''r#   c                    |dk    r|                      |dd            d S |                      |d| j        |                    d S )N
AUTOCOMMITTr   F)r   r   )r/   r   levels      r$   set_isolation_levelz%PGDialect_psycopg.set_isolation_level  su    L  $$ T4 %      $$   $ 6u = %     r#   c                    ||_         d S r+   	read_onlyr/   r   rf   s      r$   set_readonlyzPGDialect_psycopg.set_readonly  s    $
r#   c                    |j         S r+   r  r/   r   s     r$   get_readonlyzPGDialect_psycopg.get_readonly  s    ##r#   c                b     d }|g j          fd}                    |           fd}|S )Nc                :    |                      t                     d S r+   )add_notice_handlerr   )conns    r$   noticesz-PGDialect_psycopg.on_connect.<locals>.notices  s    ##L11111r#   c                >                         | j                   d S r+   )r  r   )r  r/   s    r$   
on_connectz0PGDialect_psycopg.on_connect.<locals>.on_connect  s"    ((t/CDDDDDr#   c                (    D ]} ||            d S r+   r"   )r  fnfnss     r$   r  z0PGDialect_psycopg.on_connect.<locals>.on_connect  s+      4 r#   )r   append)r/   r  r  r  s   `  @r$   r  zPGDialect_psycopg.on_connect  sx    	2 	2 	2 i+E E E E E JJz"""	 	 	 	 	 r#   c                ^    t          || j        j                  r||j        s|j        rdS dS )NTF)r`   r   Errorclosedbroken)r/   er   cursors       r$   is_disconnectzPGDialect_psycopg.is_disconnect  s=    a)** 	z/E  J$5 tur#   Fc                X   |j         j        }|s|j        j        | j        j        k    r|                                 |j        }	 |s|                     |d           |	                    |           |s|                     ||           d S d S # |s|                     ||           w w xY w)NT)
r   r   r   r   r   r   r   r   _do_autocommitexecute)r/   r   commandrecover
dbapi_connbefore_autocommits         r$   _do_prepared_twophasez'PGDialect_psycopg._do_prepared_twophase  s    *;
	" 1.34 4 !!!&1	C$ 6##J555w'''$ C##J0ABBBBBC C$ C##J0ABBBBCs   -B B)c                z    |r|                      |d| d|           d S |                     |j                   d S )NzROLLBACK PREPARED ''r#  )r&  do_rollbackr   r/   r   xidis_preparedr#  s        r$   do_rollback_twophasez&PGDialect_psycopg.do_rollback_twophase  se      	4&&8#888' '      Z233333r#   c                z    |r|                      |d| d|           d S |                     |j                   d S )NzCOMMIT PREPARED 'r(  r)  )r&  	do_commitr   r+  s        r$   do_commit_twophasez$PGDialect_psycopg.do_commit_twophase   sc      	2&&6666 '      NN:011111r#   c                    dS )N;r"   r   s    r$   _dialect_specific_select_onez.PGDialect_psycopg._dialect_specific_select_one
  s    sr#   )F)TF)Sr   r   r    driversupports_statement_cachesupports_server_side_cursorsdefault_paramstylesupports_sane_multi_rowcountr   execution_ctx_clsr   statement_compilerr   preparerr   r   r   r   update_copyr   colspecsr   Stringr   r   r'   r   r)   r   r   r9   r   rG   JSONIntIndexTyper>   JSONStrIndexTyperD   IntervalrK   r
   DaterO   DateTimerM   TimerQ   IntegerrS   SmallIntegerrU   
BigIntegerrY   r   AbstractRanger]   AbstractMultiRangerw   r   r   r   r   classmethodr   r   memoized_propertyr   r-   r;   r   rj   r   r   r   r  r	  r  r  r  r&  r.  r1  r4  __classcell__)r   s   @r$   ri   ri      s       F##' ##' 2++HO t!*	
OY	
|	
 '	
 F		

 M7	
 8	
 M&	
 M*,?	
 M*,?	
 {	
 k	
 M7	
 |	
 M7	
 j	
  !?!	
" #	
$  -%'9'	
 	
 H2'D 'D 'D 'D 'DR    M M M
= = = = =0   [
 & & [& 

 
 
 
  
 
  
 
! ! !
 
  
 
  
5 5 5    
 
 
% % %$ $ $  (  C C C C( :?4 4 4 4 :?2 2 2 2 
      r#   ri   c                      e Zd ZdZdZddZd Zed             Zej	        d             Zd	 Z
dd
Zd Zd Zd ZddZd ZdS )AsyncAdapt_psycopg_cursor_cursorawait__rowsNreturnNonec                0    || _         || _        g | _        d S r+   rP  )r/   r  rR  s      r$   r   z"AsyncAdapt_psycopg_cursor.__init__  s    


r#   c                ,    t          | j        |          S r+   )getattrrQ  r/   r   s     r$   __getattr__z%AsyncAdapt_psycopg_cursor.__getattr__  s    t|T***r#   c                    | j         j        S r+   rQ  	arraysizer   s    r$   r]  z#AsyncAdapt_psycopg_cursor.arraysize  s    |%%r#   c                    || j         _        d S r+   r\  r/   rf   s     r$   r]  z#AsyncAdapt_psycopg_cursor.arraysize   s    !&r#   c                j    | j                                          | j                                         d S r+   )rS  clearrQ  _closer   s    r$   closezAsyncAdapt_psycopg_cursor.close$  s0    
r#   c                T   |                       | j        j        ||fi |          }| j        j        }|rr|j        | j        j        k    r]|                      | j                                                  }t          |t                    st          |          | _
        n|| _
        |S r+   )rR  rQ  r!  pgresultstatus_psycopg_ExecStatus	TUPLES_OKfetchallr`   listrS  )r/   queryparamskwresultresrowss          r$   r!  z!AsyncAdapt_psycopg_cursor.execute)  s    1T\1%FF2FFGGl#  	"3:!9!CCC;;t|446677DdD)) "!$ZZ

!
r#   c                ^    |                      | j                            ||                    S r+   )rR  rQ  executemany)r/   rk  
params_seqs      r$   rr  z%AsyncAdapt_psycopg_cursor.executemany8  s&    {{4<33E:FFGGGr#   c              #  b   K   | j         r%| j                             d          V  | j         #d S d S r   rS  popr   s    r$   __iter__z"AsyncAdapt_psycopg_cursor.__iter__;  sJ      j 	$*..##### j 	$ 	$ 	$ 	$ 	$r#   c                H    | j         r| j                             d          S d S r   ru  r   s    r$   fetchonez"AsyncAdapt_psycopg_cursor.fetchone@  s%    : 	:>>!$$$4r#   c                h    || j         j        }| j        d|         }| j        |d          | _        |S r   )rQ  r]  rS  )r/   sizeretvals      r$   	fetchmanyz#AsyncAdapt_psycopg_cursor.fetchmanyG  s8    <<)DAdF#Z&
r#   c                "    | j         }g | _         |S r+   )rS  )r/   r|  s     r$   ri  z"AsyncAdapt_psycopg_cursor.fetchallO  s    
r#   rT  rU  r+   )r   r   r    	__slots__rg  r   rZ  propertyr]  setterrc  r!  rr  rw  ry  r}  ri  r"   r#   r$   rO  rO    s        .I   
+ + + & & X& ' ' '  
   H H H$ $ $
         r#   rO  c                  6    e Zd Zd	dZd Zd Zd
dZd Zd ZdS )AsyncAdapt_psycopg_ss_cursorNc                T    |                       | j        j        ||fi |           | S r+   )rR  rQ  r!  )r/   rk  rl  rm  s       r$   r!  z$AsyncAdapt_psycopg_ss_cursor.executeV  s3    (DL(=="==>>>r#   c                ^    |                      | j                                                   d S r+   )rR  rQ  rc  r   s    r$   rc  z"AsyncAdapt_psycopg_ss_cursor.closeZ  s(    DL&&(()))))r#   c                Z    |                      | j                                                  S r+   )rR  rQ  ry  r   s    r$   ry  z%AsyncAdapt_psycopg_ss_cursor.fetchone]  "    {{4<0022333r#   r   c                \    |                      | j                            |                    S r+   )rR  rQ  r}  )r/   r{  s     r$   r}  z&AsyncAdapt_psycopg_ss_cursor.fetchmany`  s$    {{4<11$77888r#   c                Z    |                      | j                                                  S r+   )rR  rQ  ri  r   s    r$   ri  z%AsyncAdapt_psycopg_ss_cursor.fetchallc  r  r#   c              #     K   | j                                         }	 	 |                     |                                          V  n# t          $ r Y d S w xY w=r+   )rQ  	__aiter__rR  	__anext__StopAsyncIteration)r/   iterators     r$   rw  z%AsyncAdapt_psycopg_ss_cursor.__iter__f  sq      <))++	kk("4"4"6"6777777%   	s   )A 
AAr+   )r   )	r   r   r    r!  rc  ry  r}  ri  rw  r"   r#   r$   r  r  U  sx           * * *4 4 49 9 9 94 4 4    r#   r  c                      e Zd ZU ded<   dZ ee          ZddZd Z	dd	Z
d
 Zd Zd Zd Zed             Zej        d             Zd Zd Zd Zd ZdS )AsyncAdapt_psycopg_connectionr   _connectionr"   rT  rU  c                    || _         d S r+   r  r  s     r$   r   z&AsyncAdapt_psycopg_connection.__init__t  s    %r#   c                ,    t          | j        |          S r+   )rX  r  rY  s     r$   rZ  z)AsyncAdapt_psycopg_connection.__getattr__w  s    t'...r#   Nc                z    |                       | j        j        ||fi |          }t          || j                   S r+   )rR  r  r!  rO  )r/   rk  rl  rm  r  s        r$   r!  z%AsyncAdapt_psycopg_connection.executez  s@    5T-5eVJJrJJKK(===r#   c                     | j         j        |i |}t          |d          rt          || j                  S t          || j                  S )Nr   )r  r  hasattrr  rR  rO  )r/   argsrm  r  s       r$   r  z$AsyncAdapt_psycopg_connection.cursor~  sS    (!($5"5566"" 	B/DDD,VT[AAAr#   c                ^    |                      | j                                                   d S r+   )rR  r  commitr   s    r$   r  z$AsyncAdapt_psycopg_connection.commit  s)    D$++--.....r#   c                ^    |                      | j                                                   d S r+   )rR  r  r   r   s    r$   r   z&AsyncAdapt_psycopg_connection.rollback  s)    D$--//00000r#   c                ^    |                      | j                                                   d S r+   )rR  r  rc  r   s    r$   rc  z#AsyncAdapt_psycopg_connection.close  s)    D$**,,-----r#   c                    | j         j        S r+   )r  r   r   s    r$   r   z(AsyncAdapt_psycopg_connection.autocommit  s    **r#   c                0    |                      |           d S r+   set_autocommitr_  s     r$   r   z(AsyncAdapt_psycopg_connection.autocommit  s    E"""""r#   c                `    |                      | j                            |                     d S r+   )rR  r  r  r_  s     r$   r  z,AsyncAdapt_psycopg_connection.set_autocommit  +    D$33E::;;;;;r#   c                `    |                      | j                            |                     d S r+   )rR  r  r  r_  s     r$   r  z1AsyncAdapt_psycopg_connection.set_isolation_level  s+    D$88??@@@@@r#   c                `    |                      | j                            |                     d S r+   )rR  r  set_read_onlyr_  s     r$   r  z+AsyncAdapt_psycopg_connection.set_read_only  s+    D$22599:::::r#   c                `    |                      | j                            |                     d S r+   )rR  r  set_deferrabler_  s     r$   r  z,AsyncAdapt_psycopg_connection.set_deferrable  r  r#   r  r+   )r   r   r    __annotations__r  staticmethodr   rR  r   rZ  r!  r  r  r   rc  r  r   r  r  r  r  r  r"   r#   r$   r  r  o  s%            I\*%%F& & & &/ / /> > > >B B B/ / /1 1 1. . . + + X+ # # #< < <A A A; ; ;< < < < <r#   r  c                  (    e Zd ZdZ ee          ZdS )%AsyncAdaptFallback_psycopg_connectionr"   N)r   r   r    r  r  r   rR  r"   r#   r$   r  r    s"        I\.))FFFr#   r  c                      e Zd ZddZd ZdS )PsycopgAdaptDBAPIrT  rU  c                |    || _         | j         j                                        D ]\  }}|dk    r
|| j        |<   d S )Nconnect)r   __dict__items)r/   r   kvs       r$   r   zPsycopgAdaptDBAPI.__init__  sM    L)//11 	% 	%DAqI~~#$a 	% 	%r#   c           	     (   |                     dd          }|                     d| j        j        j                  }t	          j        |          r"t          t           ||i |                    S t          t           ||i |                    S )Nasync_fallbackFasync_creator_fn)
rv  r   r   r  r   asboolr  r   r  r   )r/   argrm  r  
creator_fns        r$   r  zPsycopgAdaptDBAPI.connect  s     0%88VV < D
 

 ;~&& 	8zz35"5566   1::s1b1122  r#   Nr  )r   r   r    r   r  r"   r#   r$   r  r    s7        % % % %    r#   r  c                  f    e Zd ZdZdZed             Zed             Zd Zd Z	d Z
d Zd Zd	 Zd
S )r   Tc                L    dd l }ddlm} |t          _        t          |          S )Nr   )
ExecStatus)r   r   r  rO  rg  r  )r   r   r  s      r$   r   z#PGDialectAsync_psycopg.import_dbapi  s4    ))))))8B!5 )))r#   c                    |j                             dd          }t          j        |          rt          j        S t          j        S )Nr  F)rk  getr   r  r   FallbackAsyncAdaptedQueuePoolAsyncAdaptedQueuePool)r   r   r  s      r$   get_pool_classz%PGDialectAsync_psycopg.get_pool_class  s<    '7??;~&& 	.55--r#   c                x    ddl m} |j        }|                    |                    |j        |                    S r   )r   r   r   rR  r   r   )r/   r   r   r   adapteds        r$   r   z'PGDialectAsync_psycopg._type_info_fetch  s?    ******'~~hnnW-FMMNNNr#   c                Z    |                     |           |                    |           d S r+   )r  r  r   s       r$   r   z*PGDialectAsync_psycopg._do_isolation_level  s0    !!*---&&77777r#   c                0    |                     |           d S r+   r  r  s      r$   r   z%PGDialectAsync_psycopg._do_autocommit      !!%(((((r#   c                0    |                     |           d S r+   )r  r  s      r$   r	  z#PGDialectAsync_psycopg.set_readonly  s      '''''r#   c                0    |                     |           d S r+   )r  r  s      r$   r  z%PGDialectAsync_psycopg.set_deferrable  r  r#   c                    |j         S r+   r  r  s     r$   get_driver_connectionz,PGDialectAsync_psycopg.get_driver_connection  s    %%r#   N)r   r   r    is_asyncr6  rK  r   r  r   r   r   r	  r  r  r"   r#   r$   r   r     s        H#* * [* . . [.O O O8 8 8) ) )( ( () ) )& & & & &r#   r   )R__doc__
__future__r   loggingr   typingr   r    r   _psycopg_commonr   r	   baser
   r   r   r   r   r   r   r   r   r   r   r   enginer   sqlr   util.concurrencyr   r   r   r   r   	getLoggerr   r?  r   r'   r)   r9   r@  r>   rA  rD   rG   rK   rD  rM   rC  rO   rE  rQ   rF  rS   rG  rU   NullTyperW   rH  rY   Booleanr[   AbstractRangeImplr]   AbstractMultiRangeImplrw   r   r   r   r   ri   rO  r  r  r  r  r   r0   dialect_asyncr"   r#   r$   <module>r     s  , ,Z # " " " " "  				                         6 6 6 6 6 6 ? ? ? ? ? ?             & & & & & &                                           ' ' ' ' ' '       . . . . . . * * * * * * (''''''		;	<	<           9       d       u       (-8       (-8   	 	 	 	 	l 	 	 	    (       8$       hm       hm       !       h+       (#       H'       !       F,   6* * * * *6 * * *Z	 	 	 	 	!C 	 	 		 	 	 	 	 	 	 		 	 	 	 	#7 	 	 	K K KM M M M M1 M M M`C C C C C C C CL    #<   41< 1< 1< 1< 1<$5 1< 1< 1<h* * * * *,I * * *
       .*& *& *& *& *&. *& *& *&Z &r#   