o
    Šåg[  ã                   @  s$  d Z ddlm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 &d¡Z'G dd„ dej(ƒZ)G dd „ d eƒZ*G d!d"„ d"eƒZ+G d#d$„ d$eƒZ,G d%d&„ d&ejj-ƒZ.G d'd(„ d(ejj/ƒZ0G d)d*„ d*eƒZ1G d+d,„ d,eƒZ2G d-d.„ d.ej3ƒZ4G d/d0„ d0ej5ƒZ6G d1d2„ d2ej7ƒZ8G d3d4„ d4ej9ƒZ:G d5d6„ d6ej;ƒZ<G d7d8„ d8ej=ƒZ>G d9d:„ d:ej?ƒZ@G d;d<„ d<ejAƒZBG d=d>„ d>ejCƒZDG d?d@„ d@ejEƒZFG dAdB„ dBeƒZGG dCdD„ dDeƒZHG dEdF„ dFeƒZIdGdH„ ZJG dIdJ„ dJeƒZKG dKdL„ dLƒZLG dMdN„ dNeLƒZMG dOdP„ dPeƒZNG dQdR„ dReNƒZOG dSdT„ dTƒZPG dUdV„ dVeKƒZQeKZReQZSdS )Wau  
.. 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.

Using a different Cursor class
------------------------------

One of the differences between ``psycopg`` and the older ``psycopg2``
is how bound parameters are handled: ``psycopg2`` would bind them
client side, while ``psycopg`` by default will bind them server side.

It's possible to configure ``psycopg`` to do client side binding by
specifying the ``cursor_factory`` to be ``ClientCursor`` when creating
the engine::

    from psycopg import ClientCursor

    client_side_engine = create_engine(
        "postgresql+psycopg://...",
        connect_args={"cursor_factory": ClientCursor},
    )

Similarly when using an async engine the ``AsyncClientCursor`` can be
specified::

    from psycopg import AsyncClientCursor

    client_side_engine = create_async_engine(
        "postgresql+psycopg://...",
        connect_args={"cursor_factory": AsyncClientCursor},
    )

.. seealso::

    `Client-side-binding cursors <https://www.psycopg.org/psycopg3/docs/advanced/cursors.html#client-side-binding-cursors>`_

é    )Úannotations)ÚdequeN)Ú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© r"   r"   úb/var/www/html/flaskapp/venv/lib/python3.10/site-packages/sqlalchemy/dialects/postgresql/psycopg.pyr   �   ó    r   c                   @  r   )Ú_PGREGCONFIGTNr   r"   r"   r"   r#   r%   …   r$   r%   c                   @  ó   e Zd Zdd„ Zdd„ ZdS )Ú_PGJSONc                 C  ó   |   d |j¡S ©N)Ú_make_bind_processorÚ_psycopg_Json©ÚselfÚdialectr"   r"   r#   Úbind_processorŠ   ó   z_PGJSON.bind_processorc                 C  ó   d S r)   r"   ©r-   r.   Úcoltyper"   r"   r#   Úresult_processor�   ó   z_PGJSON.result_processorN©r   r   r    r/   r4   r"   r"   r"   r#   r'   ‰   ó    r'   c                   @  r&   )Ú_PGJSONBc                 C  r(   r)   )r*   Ú_psycopg_Jsonbr,   r"   r"   r#   r/   ’   r0   z_PGJSONB.bind_processorc                 C  r1   r)   r"   r2   r"   r"   r#   r4   •   r5   z_PGJSONB.result_processorNr6   r"   r"   r"   r#   r8   ‘   r7   r8   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;   ™   ó    r;   c                   @  r:   )Ú_PGJSONStrIndexTypeÚjson_str_indexTNr=   r"   r"   r"   r#   r@   Ÿ   r?   r@   c                   @  ó   e Zd ZdS )Ú_PGJSONPathTypeN©r   r   r    r"   r"   r"   r#   rC   ¥   ó    rC   c                   @  r   )Ú_PGIntervalTNr   r"   r"   r"   r#   rF   ©   r$   rF   c                   @  r   )Ú_PGTimeStampTNr   r"   r"   r"   r#   rG   ­   r$   rG   c                   @  r   )Ú_PGDateTNr   r"   r"   r"   r#   rH   ±   r$   rH   c                   @  r   )Ú_PGTimeTNr   r"   r"   r"   r#   rI   µ   r$   rI   c                   @  r   )Ú
_PGIntegerTNr   r"   r"   r"   r#   rJ   ¹   r$   rJ   c                   @  r   )Ú_PGSmallIntegerTNr   r"   r"   r"   r#   rK   ½   r$   rK   c                   @  r   )Ú_PGNullTypeTNr   r"   r"   r"   r#   rL   Á   r$   rL   c                   @  r   )Ú_PGBigIntegerTNr   r"   r"   r"   r#   rM   Å   r$   rM   c                   @  r   )Ú
_PGBooleanTNr   r"   r"   r"   r#   rN   É   r$   rN   c                   @  r&   )Ú_PsycopgRangec                   s   t t|ƒj‰ ‡ fdd„}|S )Nc                   s&   t | tjƒrˆ | j| j| j| jƒ} | S r)   )Ú
isinstancer   ÚRangeÚlowerÚupperÚboundsÚempty©Úvalue©Úpsycopg_Ranger"   r#   Úto_rangeÑ   s
   ÿz._PsycopgRange.bind_processor.<locals>.to_range)r   ÚPGDialect_psycopgÚ_psycopg_Range©r-   r.   rZ   r"   rX   r#   r/   Î   s   z_PsycopgRange.bind_processorc                 C  ó   dd„ }|S )Nc                 S  s2   | d urt j| j| j| jr| jnd| j d�} | S )Nú[)©rT   rU   ©r   rQ   Ú_lowerÚ_upperÚ_boundsrV   r"   r"   r#   rZ   Û   s   üz0_PsycopgRange.result_processor.<locals>.to_ranger"   ©r-   r.   r3   rZ   r"   r"   r#   r4   Ú   s   
z_PsycopgRange.result_processorNr6   r"   r"   r"   r#   rO   Í   s    rO   c                   @  r&   )Ú_PsycopgMultiRangec                   s4   t t|ƒj‰t t|ƒj‰td ƒ‰ ‡ ‡‡fdd„}|S )Nc                   s0   t | tˆ ˆfƒr
| S ˆ‡fdd„td| ƒD ƒƒS )Nc                   s"   g | ]}ˆ |j |j|j|jƒ‘qS r"   )rR   rS   rT   rU   )Ú.0ÚelementrX   r"   r#   Ú
<listcomp>ö   s    úüÿzG_PsycopgMultiRange.bind_processor.<locals>.to_range.<locals>.<listcomp>zIterable[ranges.Range])rP   Ústrr   rV   ©ÚNoneTypeÚpsycopg_MultirangerY   r"   r#   rZ   ñ   s   
ùÿz3_PsycopgMultiRange.bind_processor.<locals>.to_range)r   r[   r\   Ú_psycopg_MultirangeÚtyper]   r"   rk   r#   r/   é   s   ÿþz!_PsycopgMultiRange.bind_processorc                 C  r^   )Nc                 S  s    | d u rd S t  dd„ | D ƒ¡S )Nc                 s  s6   � | ]}t j|j|j|jr|jnd |j d�V  qdS )r_   r`   Nra   )rg   Úelemr"   r"   r#   Ú	<genexpr>  s   € úü
ÿzH_PsycopgMultiRange.result_processor.<locals>.to_range.<locals>.<genexpr>)r   Ú
MultiRangerV   r"   r"   r#   rZ     s
   
ùz5_PsycopgMultiRange.result_processor.<locals>.to_ranger"   re   r"   r"   r#   r4     s   z#_PsycopgMultiRange.result_processorNr6   r"   r"   r"   r#   rf   è   s    rf   c                   @  rB   )ÚPGExecutionContext_psycopgNrD   r"   r"   r"   r#   rs     rE   rs   c                   @  rB   )ÚPGCompiler_psycopgNrD   r"   r"   r"   r#   rt     rE   rt   c                   @  rB   )ÚPGIdentifierPreparer_psycopgNrD   r"   r"   r"   r#   ru     rE   ru   c                 C  s   t  d| j| j¡ d S )Nz%s: %s)ÚloggerÚinfoÚseverityÚmessage_primary)Ú
diagnosticr"   r"   r#   Ú_log_notices!  ó   r{   c                      sâ  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 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j0e1“ej2e3“e4j5e6e4j7e8i¥¡Z‡ fdd„Z9‡ fdd	„Z:d
d„ Z;‡ fdd„Z<e=dd„ ƒZ>e=dd„ ƒZ?ej@dd„ ƒZAej@dd„ ƒZBej@dd„ ƒZCej@dd„ ƒZDej@dd„ ƒZEej@dd„ ƒZFdd„ ZG‡ fd d!„ZHd"d#„ ZId$d%„ ZJd&d'„ ZKd(d)„ ZLd*d+„ ZMd5d-d.„ZN	,d6d/d0„ZO	,d6d1d2„ZPej@d3d4„ ƒZQ‡  ZRS )7r[   ÚpsycopgTÚpyformat)r   r   Nc                   sø   t ƒ jdi |¤Ž | jrxt d| jj¡}|r%tdd„ | ddd¡D ƒƒ| _| jdk r.t	dƒ‚d	d
l
m} || jjƒ | _}| jdu rXd	d l}| d|jjj¡ | d|jjj¡ | jrgd	dlm} || j|ƒ | jrzd	dlm} || j|ƒ d S d S d S )Nz(\d+)\.(\d+)(?:\.(\d+))?c                 s  s    � | ]}|d urt |ƒV  qd S r)   )Úint)rg   Úxr"   r"   r#   rq   T  s   € ÿz-PGDialect_psycopg.__init__.<locals>.<genexpr>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__r"   r#   rˆ   N  s>   
ÿ
ÿ
ÿ

ÿ
ÿÜ!zPGDialect_psycopg.__init__c                   s<   t ƒ  |¡\}}| jr| j|d< | jd ur| j|d< ||fS )NÚcontextÚclient_encoding)r‡   Úcreate_connect_argsr“   r£   )r-   ÚurlÚcargsÚcparamsr    r"   r#   r¤   w  s   


z%PGDialect_psycopg.create_connect_argsc                 C  s   ddl m} | |jj|¡S ©Nr   )ÚTypeInfo)Úpsycopg.typesr©   ÚfetchÚ
connectionÚdriver_connection)r-   r¬   Únamer©   r"   r"   r#   Ú_type_info_fetch�  s   z"PGDialect_psycopg._type_info_fetchc                   s€   t ƒ  |¡ | jsd| _| jr<|  |d¡}|d u| _| jr>ddlm} | j	s(J ‚||| j	ƒ |j
s3J ‚|||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¬   rw   r±   r    r"   r#   r²   †  s   


ózPGDialect_psycopg.initializec                 C  s   dd l }|S )Nr   )r}   )Úclsr}   r"   r"   r#   Úimport_dbapi   s   zPGDialect_psycopg.import_dbapic                 C  s   t S r)   )ÚPGDialectAsync_psycopg)r¸   r¥   r"   r"   r#   Úget_async_dialect_cls¦  ó   z'PGDialect_psycopg.get_async_dialect_clsc                 C  s&   | 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-   r"   r"   r#   Ú_isolation_lookupª  s
   üz#PGDialect_psycopg._isolation_lookupc                 C  ó   ddl m} |jS ©Nr   )Újson)rª   rÆ   ÚJson©r-   rÆ   r"   r"   r#   r+   ³  ó   zPGDialect_psycopg._psycopg_Jsonc                 C  rÄ   rÅ   )rª   rÆ   ÚJsonbrÈ   r"   r"   r#   r9   ¹  rÉ   z PGDialect_psycopg._psycopg_Jsonbc                 C  ó   ddl m} |S )Nr   )ÚTransactionStatus)Ú
psycopg.pqrÌ   )r-   rÌ   r"   r"   r#   Ú_psycopg_TransactionStatus¿  ó   z,PGDialect_psycopg._psycopg_TransactionStatusc                 C  rË   )Nr   )rQ   )Úpsycopg.types.rangerQ   )r-   rQ   r"   r"   r#   r\   Å  rÏ   z PGDialect_psycopg._psycopg_Rangec                 C  rË   )Nr   )Ú
Multirange)Úpsycopg.types.multirangerÑ   )r-   rÑ   r"   r"   r#   rn   Ë  rÏ   z%PGDialect_psycopg._psycopg_Multirangec                 C  s   ||_ ||_d S r)   ©Ú
autocommitÚisolation_level©r-   r¬   rÔ   rÕ   r"   r"   r#   Ú_do_isolation_levelÑ  s   
z%PGDialect_psycopg._do_isolation_levelc                   s,   |j j}tƒ  |¡}|| jjkr| ¡  |S r)   )rw   Útransaction_statusr‡   Úget_isolation_levelrÎ   ÚIDLEÚrollback)r-   Údbapi_connectionÚstatus_beforerW   r    r"   r#   rÙ   Õ  s
   z%PGDialect_psycopg.get_isolation_levelc                 C  s6   |dkr| j |dd d� d S | j |d| j| d� d S )NÚ
AUTOCOMMITTrÓ   F)r×   rÃ   )r-   rÜ   Úlevelr"   r"   r#   Úset_isolation_levelß  s   
ÿ
ýz%PGDialect_psycopg.set_isolation_levelc                 C  s
   ||_ d S r)   ©Ú	read_only©r-   r¬   rW   r"   r"   r#   Úset_readonlyë  ó   
zPGDialect_psycopg.set_readonlyc                 C  ó   |j S r)   rá   ©r-   r¬   r"   r"   r#   Úget_readonlyî  ó   zPGDialect_psycopg.get_readonlyc                   s>   dd„ }|g‰ ˆj d ur‡fdd„}ˆ  |¡ ‡ fdd„}|S )Nc                 S  s   |   t¡ d S r)   )Úadd_notice_handlerr{   ©Úconnr"   r"   r#   Únoticesò  r0   z-PGDialect_psycopg.on_connect.<locals>.noticesc                   s   ˆ   | ˆ j¡ d S r)   )rà   rÕ   rë   rÂ   r"   r#   Ú
on_connectù  ó   z0PGDialect_psycopg.on_connect.<locals>.on_connectc                   s   ˆ D ]}|| ƒ qd S r)   r"   )rì   Úfn)Úfnsr"   r#   rî   ÿ  s   
ÿ)rÕ   Úappend)r-   rí   rî   r"   )rñ   r-   r#   rî   ñ  s   

zPGDialect_psycopg.on_connectc                 C  s*   t || jjƒr|d ur|js|jrdS dS )NTF)rP   r‰   ÚErrorÚclosedÚbroken)r-   Úer¬   Úcursorr"   r"   r#   Úis_disconnect  s   zPGDialect_psycopg.is_disconnectFc              
   C  st   |j j}|s|jj| jjkr| ¡  |j}z|s|  |d¡ | 	|¡ W |s.|  ||¡ d S d S |s9|  ||¡ w w )NT)
r¬   rÜ   rw   rØ   rÎ   rÚ   rÛ   rÔ   Ú_do_autocommitÚexecute)r-   r¬   ÚcommandÚrecoverÚ
dbapi_connÚbefore_autocommitr"   r"   r#   Ú_do_prepared_twophase  s"   ÿÿÿÿz'PGDialect_psycopg._do_prepared_twophasec                 C  ó0   |r| j |d|› d�|d� d S |  |j¡ d S )NzROLLBACK PREPARED 'ú'©rü   )rÿ   Údo_rollbackr¬   ©r-   r¬   ÚxidÚis_preparedrü   r"   r"   r#   Údo_rollback_twophase  ó
   
ÿz&PGDialect_psycopg.do_rollback_twophasec                 C  r   )NzCOMMIT PREPARED 'r  r  )rÿ   Ú	do_commitr¬   r  r"   r"   r#   Údo_commit_twophase(  r  z$PGDialect_psycopg.do_commit_twophasec                 C  s   dS )Nú;r"   rÂ   r"   r"   r#   Ú_dialect_specific_select_one2  r¼   z.PGDialect_psycopg._dialect_specific_select_one)F)TF)Sr   r   r    ÚdriverÚsupports_statement_cacheÚsupports_server_side_cursorsÚdefault_paramstyleÚsupports_sane_multi_rowcountrs   Úexecution_ctx_clsrt   Ústatement_compilerru   Úpreparerr�   r¶   r“   r   Úupdate_copyr   Úcolspecsr   ÚStringr   r   r%   r   r'   r   r   r8   r   rC   ÚJSONIntIndexTyper;   ÚJSONStrIndexTyper@   ÚIntervalrF   r
   ÚDaterH   ÚDateTimerG   ÚTimerI   ÚIntegerrJ   ÚSmallIntegerrK   Ú
BigIntegerrM   r   ÚAbstractSingleRangerO   ÚAbstractMultiRangerf   rˆ   r¤   r¯   r²   Úclassmethodr¹   r»   Úmemoized_propertyrÃ   r+   r9   rÎ   r\   rn   r×   rÙ   rà   rä   rè   rî   rø   rÿ   r  r
  r  Ú__classcell__r"   r"   r    r#   r[   %  s®    ÿþýüûúùø	÷
öõôóòñðïíþ)











ÿ
ÿ
r[   c                   @  s|   e Zd ZdZdZddd„Zdd„ Zed	d
„ ƒZej	dd
„ ƒZdd„ Z
ddd„Zdd„ Zdd„ Zdd„ Zddd„Zdd„ ZdS )ÚAsyncAdapt_psycopg_cursor)Ú_cursorÚawait_Ú_rowsNÚreturnÚNonec                 C  s   || _ || _tƒ | _d S r)   )r'  r(  r   r)  )r-   r÷   r(  r"   r"   r#   rˆ   <  s   z"AsyncAdapt_psycopg_cursor.__init__c                 C  ó   t | j|ƒS r)   )Úgetattrr'  ©r-   r®   r"   r"   r#   Ú__getattr__A  ó   z%AsyncAdapt_psycopg_cursor.__getattr__c                 C  ó   | j jS r)   ©r'  Ú	arraysizerÂ   r"   r"   r#   r3  D  ó   z#AsyncAdapt_psycopg_cursor.arraysizec                 C  s   || j _d S r)   r2  ©r-   rW   r"   r"   r#   r3  H  s   c                 C  s   | j  ¡  | j ¡  d S r)   )r)  Úclearr'  Ú_closerÂ   r"   r"   r#   ÚcloseL  s   
zAsyncAdapt_psycopg_cursor.closec                 K  sT   |   | jj||fi |¤Ž¡}| jj}|r(|j| jjkr(|   | j ¡ ¡}t|ƒ| _	|S r)   )
r(  r'  rú   ÚpgresultÚstatusÚ_psycopg_ExecStatusÚ	TUPLES_OKÚfetchallr   r)  )r-   ÚqueryÚparamsÚkwÚresultÚresÚrowsr"   r"   r#   rú   Q  s   
z!AsyncAdapt_psycopg_cursor.executec                 C  s   |   | j ||¡¡S r)   )r(  r'  Úexecutemany)r-   r>  Ú
params_seqr"   r"   r#   rD  ]  ó   z%AsyncAdapt_psycopg_cursor.executemanyc                 c  s"   � | j r| j  ¡ V  | j sd S d S r)   ©r)  ÚpopleftrÂ   r"   r"   r#   Ú__iter__`  s   €ÿz"AsyncAdapt_psycopg_cursor.__iter__c                 C  s   | j r| j  ¡ S d S r)   rG  rÂ   r"   r"   r#   Úfetchoned  s   
z"AsyncAdapt_psycopg_cursor.fetchonec                   s6   |d u r| j j}| j‰ ‡ fdd„tt|tˆ ƒƒƒD ƒS )Nc                   s   g | ]}ˆ   ¡ ‘qS r"   )rH  )rg   Ú_©Úrrr"   r#   ri   o  s    z7AsyncAdapt_psycopg_cursor.fetchmany.<locals>.<listcomp>)r'  r3  r)  ÚrangeÚminÚlen©r-   Úsizer"   rL  r#   Ú	fetchmanyj  s    z#AsyncAdapt_psycopg_cursor.fetchmanyc                 C  s   t | jƒ}| j ¡  |S r)   )Úlistr)  r6  )r-   Úretvalr"   r"   r#   r=  q  s   

z"AsyncAdapt_psycopg_cursor.fetchall©r*  r+  r)   )r   r   r    Ú	__slots__r;  rˆ   r/  Úpropertyr3  Úsetterr8  rú   rD  rI  rJ  rS  r=  r"   r"   r"   r#   r&  7  s     




r&  c                   @  s@   e Zd Zddd„Zdd„ Zdd„ Zdd	d
„Zdd„ Zdd„ ZdS )ÚAsyncAdapt_psycopg_ss_cursorNc                 K  s    |   | jj||fi |¤Ž¡ | S r)   )r(  r'  rú   )r-   r>  r?  r@  r"   r"   r#   rú   x  s   z$AsyncAdapt_psycopg_ss_cursor.executec                 C  ó   |   | j ¡ ¡ d S r)   )r(  r'  r8  rÂ   r"   r"   r#   r8  |  rF  z"AsyncAdapt_psycopg_ss_cursor.closec                 C  ó   |   | j ¡ ¡S r)   )r(  r'  rJ  rÂ   r"   r"   r#   rJ    ó   z%AsyncAdapt_psycopg_ss_cursor.fetchoner   c                 C  s   |   | j |¡¡S r)   )r(  r'  rS  rQ  r"   r"   r#   rS  ‚  rï   z&AsyncAdapt_psycopg_ss_cursor.fetchmanyc                 C  r\  r)   )r(  r'  r=  rÂ   r"   r"   r#   r=  …  r]  z%AsyncAdapt_psycopg_ss_cursor.fetchallc                 c  s:   � | j  ¡ }	 z
|  | ¡ ¡V  W n
 ty   Y d S w qr)   )r'  Ú	__aiter__r(  Ú	__anext__ÚStopAsyncIteration)r-   Úiteratorr"   r"   r#   rI  ˆ  s   €
ÿýz%AsyncAdapt_psycopg_ss_cursor.__iter__r)   )r   )	r   r   r    rú   r8  rJ  rS  r=  rI  r"   r"   r"   r#   rZ  w  s    

rZ  c                   @  s˜   e Zd ZU ded< dZeeƒZd dd„Zdd	„ Z	d!dd„Z
dd„ Zdd„ Zdd„ Zdd„ Zedd„ ƒZejdd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zd
S )"ÚAsyncAdapt_psycopg_connectionr   Ú_connectionr"   r*  r+  c                 C  s
   || _ d S r)   ©rc  rç   r"   r"   r#   rˆ   –  rå   z&AsyncAdapt_psycopg_connection.__init__c                 C  r,  r)   )r-  rc  r.  r"   r"   r#   r/  ™  r0  z)AsyncAdapt_psycopg_connection.__getattr__Nc                 K  s(   |   | jj||fi |¤Ž¡}t|| j ƒS r)   )r(  rc  rú   r&  )r-   r>  r?  r@  r÷   r"   r"   r#   rú   œ  s   z%AsyncAdapt_psycopg_connection.executec                 O  s4   | j j|i |¤Ž}t|dƒrt|| jƒS t|| jƒS )Nr®   )rc  r÷   ÚhasattrrZ  r(  r&  )r-   Úargsr@  r÷   r"   r"   r#   r÷      s   
z$AsyncAdapt_psycopg_connection.cursorc                 C  r[  r)   )r(  rc  ÚcommitrÂ   r"   r"   r#   rg  §  rF  z$AsyncAdapt_psycopg_connection.commitc                 C  r[  r)   )r(  rc  rÛ   rÂ   r"   r"   r#   rÛ   ª  rF  z&AsyncAdapt_psycopg_connection.rollbackc                 C  r[  r)   )r(  rc  r8  rÂ   r"   r"   r#   r8  ­  rF  z#AsyncAdapt_psycopg_connection.closec                 C  r1  r)   )rc  rÔ   rÂ   r"   r"   r#   rÔ   °  r4  z(AsyncAdapt_psycopg_connection.autocommitc                 C  s   |   |¡ d S r)   ©Úset_autocommitr5  r"   r"   r#   rÔ   ´  s   c                 C  ó   |   | j |¡¡ d S r)   )r(  rc  ri  r5  r"   r"   r#   ri  ¸  r|   z,AsyncAdapt_psycopg_connection.set_autocommitc                 C  rj  r)   )r(  rc  rà   r5  r"   r"   r#   rà   »  r|   z1AsyncAdapt_psycopg_connection.set_isolation_levelc                 C  rj  r)   )r(  rc  Úset_read_onlyr5  r"   r"   r#   rk  ¾  r|   z+AsyncAdapt_psycopg_connection.set_read_onlyc                 C  rj  r)   )r(  rc  Úset_deferrabler5  r"   r"   r#   rl  Á  r|   z,AsyncAdapt_psycopg_connection.set_deferrablerV  r)   )r   r   r    Ú__annotations__rW  Ústaticmethodr   r(  rˆ   r/  rú   r÷   rg  rÛ   r8  rX  rÔ   rY  ri  rà   rk  rl  r"   r"   r"   r#   rb  ‘  s&   
 



rb  c                   @  s   e Zd ZdZeeƒZdS )Ú%AsyncAdaptFallback_psycopg_connectionr"   N)r   r   r    rW  rn  r   r(  r"   r"   r"   r#   ro  Å  s    ro  c                   @  s   e Zd Zddd„Zdd„ ZdS )	ÚPsycopgAdaptDBAPIr*  r+  c                 C  s2   || _ | j j ¡ D ]\}}|dkr|| j|< q	d S )NÚconnect)r}   Ú__dict__Úitems)r-   r}   ÚkÚvr"   r"   r#   rˆ   Ë  s   
€þzPsycopgAdaptDBAPI.__init__c                 O  sT   |  dd¡}|  d| jjj¡}t |¡rtt||i |¤ŽƒƒS tt	||i |¤ŽƒƒS )NÚasync_fallbackFÚasync_creator_fn)
Úpopr}   r   rq  r   Úasboolro  r   rb  r   )r-   Úargr@  rv  Ú
creator_fnr"   r"   r#   rq  Ò  s   
ÿ
ÿÿzPsycopgAdaptDBAPI.connectNrV  )r   r   r    rˆ   rq  r"   r"   r"   r#   rp  Ê  s    
rp  c                   @  s\   e Zd ZdZdZedd„ ƒZedd„ ƒZdd„ Zdd	„ Z	d
d„ Z
dd„ Zdd„ Zdd„ ZdS )rº   Tc                 C  s"   dd l }ddlm} |t_t|ƒS )Nr   )Ú
ExecStatus)r}   rÍ   r|  r&  r;  rp  )r¸   r}   r|  r"   r"   r#   r¹   å  s   z#PGDialectAsync_psycopg.import_dbapic                 C  s$   |j  dd¡}t |¡rtjS tjS )Nrv  F)r>  Úgetr   ry  r   ÚFallbackAsyncAdaptedQueuePoolÚAsyncAdaptedQueuePool)r¸   r¥   rv  r"   r"   r#   Úget_pool_classî  s   
z%PGDialectAsync_psycopg.get_pool_classc                 C  s&   ddl m} |j}| | |j|¡¡S r¨   )rª   r©   r¬   r(  r«   r­   )r-   r¬   r®   r©   Úadaptedr"   r"   r#   r¯   ÷  s   z'PGDialectAsync_psycopg._type_info_fetchc                 C  s   |  |¡ | |¡ d S r)   )ri  rà   rÖ   r"   r"   r#   r×   ý  s   
z*PGDialectAsync_psycopg._do_isolation_levelc                 C  ó   |  |¡ d S r)   rh  rã   r"   r"   r#   rù     r0   z%PGDialectAsync_psycopg._do_autocommitc                 C  r‚  r)   )rk  rã   r"   r"   r#   rä     r0   z#PGDialectAsync_psycopg.set_readonlyc                 C  r‚  r)   )rl  rã   r"   r"   r#   rl    r0   z%PGDialectAsync_psycopg.set_deferrablec                 C  ræ   r)   rd  rç   r"   r"   r#   Úget_driver_connection
  ré   z,PGDialectAsync_psycopg.get_driver_connectionN)r   r   r    Úis_asyncr  r#  r¹   r€  r¯   r×   rù   rä   rl  rƒ  r"   r"   r"   r#   rº   á  s    

rº   )TÚ__doc__Ú
__future__r   Úcollectionsr   Ú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   Ú	getLoggerrv   r  r   r%   r'   r8   r  r;   r  r@   rC   rF   r  rG   r  rH   r  rI   r  rJ   r  rK   ÚNullTyperL   r   rM   ÚBooleanrN   ÚAbstractSingleRangeImplrO   ÚAbstractMultiRangeImplrf   rs   rt   ru   r{   r[   r&  rZ  rb  ro  rp  rº   r.   Údialect_asyncr"   r"   r"   r#   Ú<module>   sz   V
-  @4-