o
    DDi                     @  sr  U d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
mZmZmZ ddlmZ ddlmZ ddlmZmZmZ ercdd	lmZ dd
lmZmZ ddlmZ ddlmZmZ ddlm Z  ddl!m"Z" e#dZ$de%d< ee&e'e(f Z)de%d< eee&ddf Z*de%d< ee*ef Z+de%d< eee ee,ef f Z-de%d< edddZ.e
g df Z/de%d< ee#e0d f Z1de%d< ee,e2df Z3de%d< e4e,e3f Z5de%d < ee,e3f Z6de%d!< ed"Z7ee0e2d#f d$e7f Z8de%d%< 	 ed#d$e7f Z9de%d&< 	 G d'd( d(eZ:e
ege)dB f Z;de%d)< e
e)gef Z<de%d*< G d+d, d,eZ=G d-d. d.eZ>G d/d0 d0eZ?G d1d2 d2eZ@dS )3zN
Protocol objects representing different implementations of the same classes.
    )annotations)TYPE_CHECKINGAnyProtocol	TypeAliasUnion)Callable	GeneratorMappingSequence   )pq)PyFormat)LiteralStringTemplateTypeVar)sql)RowRowMaker)PGresult)ReadyWait)AdaptersMap)BaseConnectionNtypeNoneTyper   Bufferzsql.SQLzsql.ComposedQueryNoTemplateQueryParamsConnectionTypezBaseConnection[Any])boundPipelineCommand)	DumperKey.r#   	ConnParamConnDictConnMappingRVr   zReady | int	PQGenConnPQGenc                   @  s   e Zd ZdZddddZdS )WaitFunczU
    Wait on the connection which generated `PQgen` and return its final result.
    .gen	PQGen[RV]filenointintervalfloatreturnr'   c                 C     d S N )selfr+   r-   r/   r4   r4   D/var/www/Datamplify/venv/lib/python3.10/site-packages/psycopg/abc.py__call__<       zWaitFunc.__call__N).)r+   r,   r-   r.   r/   r0   r1   r'   )__name__
__module____qualname____doc__r7   r4   r4   r4   r6   r*   7   s    r*   DumpFuncLoadFuncc                   @  s,   e Zd ZdZed
ddZedddZd	S )AdaptContextaO  
    A context describing how types are adapted.

    Example of `!AdaptContext` are `~psycopg.Connection`, `~psycopg.Cursor`,
    `~psycopg.adapt.Transformer`, `~psycopg.adapt.AdaptersMap`.

    Note that this is a `~typing.Protocol`, so objects implementing
    `!AdaptContext` don't need to explicitly inherit from this class.

    r1   r   c                 C     dS )z1The adapters configuration that this object uses.Nr4   r5   r4   r4   r6   adaptersQ   s   zAdaptContext.adaptersBaseConnection[Any] | Nonec                 C  r@   )zThe connection used by this object, if available.

        :rtype: `~psycopg.Connection` or `~psycopg.AsyncConnection` or `!None`
        Nr4   rA   r4   r4   r6   
connectionV      zAdaptContext.connectionNr1   r   r1   rC   )r9   r:   r;   r<   propertyrB   rD   r4   r4   r4   r6   r?   E   s    r?   c                   @  sZ   e Zd ZU dZded< 	 ded< 	 ddddZdddZdddZd ddZd!ddZ	dS )"DumperzM
    Convert Python objects of type `!cls` to PostgreSQL representation.
    	pq.Formatformatr.   oidNclsr   contextAdaptContext | Nonec                 C  r2   r3   r4   )r5   rM   rN   r4   r4   r6   __init__o   r8   zDumper.__init__objr   r1   Buffer | Nonec                 C  r@   )zlConvert the object `!obj` to PostgreSQL representation.

        :param obj: the object to convert.
        Nr4   r5   rQ   r4   r4   r6   dumpq      zDumper.dumpr   c                 C  r@   )ziConvert the object `!obj` to escaped representation.

        :param obj: the object to convert.
        Nr4   rS   r4   r4   r6   quotex   rU   zDumper.quoter   r#   c                 C  r@   )a  Return an alternative key to upgrade the dumper to represent `!obj`.

        :param obj: The object to convert
        :param format: The format to convert to

        Normally the type of the object is all it takes to define how to dump
        the object to the database. For instance, a Python `~datetime.date` can
        be simply converted into a PostgreSQL :sql:`date`.

        In a few cases, just the type is not enough. For example:

        - A Python `~datetime.datetime` could be represented as a
          :sql:`timestamptz` or a :sql:`timestamp`, according to whether it
          specifies a `!tzinfo` or not.

        - A Python int could be stored as several Postgres types: int2, int4,
          int8, numeric. If a type too small is used, it may result in an
          overflow. If a type too large is used, PostgreSQL may not want to
          cast it to a smaller type.

        - Python lists should be dumped according to the type they contain to
          convert them to e.g. array of strings, array of ints (and which
          size of int?...)

        In these cases, a dumper can implement `!get_key()` and return a new
        class, or sequence of classes, that can be used to identify the same
        dumper again. If the mechanism is not needed, the method should return
        the same `!cls` object passed in the constructor.

        If a dumper implements `get_key()` it should also implement
        `upgrade()`.

        Nr4   r5   rQ   rK   r4   r4   r6   get_key   s   "zDumper.get_keyc                 C  r@   )a  Return a new dumper to manage `!obj`.

        :param obj: The object to convert
        :param format: The format to convert to

        Once `Transformer.get_dumper()` has been notified by `get_key()` that
        this Dumper class cannot handle `!obj` itself, it will invoke
        `!upgrade()`, which should return a new `Dumper` instance, which will
        be reused for every objects for which `!get_key()` returns the same
        result.
        Nr4   rW   r4   r4   r6   upgrade   s   zDumper.upgrader3   )rM   r   rN   rO   )rQ   r   r1   rR   )rQ   r   r1   r   )rQ   r   rK   r   r1   r#   rQ   r   rK   r   r1   rI   )
r9   r:   r;   r<   __annotations__rP   rT   rV   rX   rY   r4   r4   r4   r6   rI   _   s   
 


$rI   c                   @  s2   e Zd ZU dZded< 	 ddd	d
ZdddZdS )LoaderzK
    Convert PostgreSQL values with type OID `!oid` to Python objects.
    rJ   rK   NrL   r.   rN   rO   c                 C  r2   r3   r4   )r5   rL   rN   r4   r4   r6   rP      r8   zLoader.__init__datar   r1   r   c                 C  r@   )z|
        Convert the data returned by the database into a Python object.

        :param data: the data to convert.
        Nr4   )r5   r]   r4   r4   r6   load   rE   zLoader.loadr3   )rL   r.   rN   rO   )r]   r   r1   r   )r9   r:   r;   r<   r[   rP   r^   r4   r4   r4   r6   r\      s   
 r\   c                   @  s   e Zd ZU ded< ded< dLdMdd	ZedNddZedOddZedPddZ	edQddZ
edRddZddddSd!d"ZdTd%d&ZdTd'd(ZdUd-d.ZdVd2d3ZdWd6d7ZdXd>d?ZdYdBdCZdZdFdGZd[dJdKZdS )\Transformerztuple[int, ...] | Nonetypeszlist[pq.Format] | NoneformatsNrN   rO   c                 C  r2   r3   r4   )r5   rN   r4   r4   r6   rP      r8   zTransformer.__init__r1   c                 C  r2   r3   r4   )rM   rN   r4   r4   r6   from_context      zTransformer.from_contextrC   c                 C  r2   r3   r4   rA   r4   r4   r6   rD      rc   zTransformer.connectionstrc                 C  r2   r3   r4   rA   r4   r4   r6   encoding   rc   zTransformer.encodingr   c                 C  r2   r3   r4   rA   r4   r4   r6   rB      rc   zTransformer.adaptersPGresult | Nonec                 C  r2   r3   r4   rA   r4   r4   r6   pgresult   rc   zTransformer.pgresultT)set_loadersrK   resultrh   boolrK   pq.Format | NoneNonec                C  r2   r3   r4   )r5   ri   rh   rK   r4   r4   r6   set_pgresult   rE   zTransformer.set_pgresultSequence[int]rJ   c                 C  r2   r3   r4   r5   r`   rK   r4   r4   r6   set_dumper_types   r8   zTransformer.set_dumper_typesc                 C  r2   r3   r4   ro   r4   r4   r6   set_loader_types   r8   zTransformer.set_loader_typesparamsSequence[Any]Sequence[PyFormat]Sequence[Buffer | None]c                 C  r2   r3   r4   )r5   rr   ra   r4   r4   r6   dump_sequence   s   zTransformer.dump_sequencerQ   r   bytesc                 C  r2   r3   r4   rS   r4   r4   r6   
as_literal   r8   zTransformer.as_literalr   rI   c                 C  r2   r3   r4   rW   r4   r4   r6   
get_dumper   r8   zTransformer.get_dumperrow0r.   row1make_rowRowMaker[Row]	list[Row]c                 C  r2   r3   r4   )r5   rz   r{   r|   r4   r4   r6   	load_rows   r8   zTransformer.load_rowsrowr   c                 C  r2   r3   r4   )r5   r   r|   r4   r4   r6   load_row   r8   zTransformer.load_rowrecordtuple[Any, ...]c                 C  r2   r3   r4   )r5   r   r4   r4   r6   load_sequence   r8   zTransformer.load_sequencerL   r\   c                 C  r2   r3   r4   )r5   rL   rK   r4   r4   r6   
get_loader   r8   zTransformer.get_loaderr3   )rN   rO   )rN   rO   r1   r_   rG   )r1   rd   rF   )r1   rf   )ri   rf   rh   rj   rK   rk   r1   rl   )r`   rn   rK   rJ   r1   rl   )rr   rs   ra   rt   r1   ru   )rQ   r   r1   rw   rZ   )rz   r.   r{   r.   r|   r}   r1   r~   )r   r.   r|   r}   r1   r   )r   ru   r1   r   )rL   r.   rK   rJ   r1   r\   )r9   r:   r;   r[   rP   classmethodrb   rH   rD   re   rB   rg   rm   rp   rq   rv   rx   ry   r   r   r   r   r4   r4   r4   r6   r_      s4   
 







r_   )Ar<   
__future__r   typingr   r   r   r   r   collections.abcr   r	   r
   r    r   _enumsr   _compatr   r   r   r   rowsr   r   pq.abcr   waitingr   r   _adapters_mapr   _connection_baser   r   r   r[   rw   	bytearray
memoryviewr   r   r   rd   r   r    r"   tupler#   r.   r$   dictr%   r&   r'   r(   r)   r*   r=   r>   r?   rI   r\   r_   r4   r4   r4   r6   <module>   sJ     
S