o
    TPf                     @  s
  U d Z ddlmZ ddlmZmZmZmZ ddlmZm	Z	m
Z
 ddlmZ ddlmZ ddl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 ddlmZ e dZ!de"d< dZ#de"d< dZ$de"d< dZ%de"d< edddZ&eg df Z'de"d< dZ(de"d< d Z)de"d!< d"Z*de"d#< ee+e)f Z,de"d$< ed%Z-ed&d'e-f Z.de"d(< 	 ed)d'e-f Z/de"d*< 	 G d+d, d,eZ0eegd-f Z1de"d.< ee#gef Z2de"d/< G d0d1 d1eZ3G d2d3 d3eZ4G d4d5 d5eZ5G d6d7 d7eZ6dS )8zN
Protocol objects representing different implementations of the same classes.
    )annotations)AnyCallable	GeneratorMapping)ProtocolSequenceTYPE_CHECKING   )pq)PyFormat)	TypeAliasTypeVar)sql)RowRowMaker)PGresult)WaitReady)LiteralString)AdaptersMap)BaseConnectionNtypeNoneTypezbytes | bytearray | memoryviewr   Bufferz.LiteralString | bytes | sql.SQL | sql.ComposedQueryz!Sequence[Any] | Mapping[str, Any]ParamsConnectionTypezBaseConnection[Any])boundPipelineCommandztype | tuple[DumperKey, ...]	DumperKeyzstr | int | None	ConnParamzdict[str, ConnParam]ConnDictConnMappingRVztuple[int, Wait]zReady | int	PQGenConnr   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.
    Ngen	PQGen[RV]filenointintervalfloat | Nonereturnr$   c                 C     d S N )selfr(   r*   r,   r1   r1   W/var/www/html/Testing_prj/Navya-Bakers/venv/lib/python3.10/site-packages/psycopg/abc.py__call__<      zWaitFunc.__call__r0   )r(   r)   r*   r+   r,   r-   r.   r$   )__name__
__module____qualname____doc__r4   r1   r1   r1   r3   r'   7   s    r'   Buffer | None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.

    r.   r   c                 C     dS )z1The adapters configuration that this object uses.Nr1   r2   r1   r1   r3   adaptersS   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`
        Nr1   r?   r1   r1   r3   
connectionX      zAdaptContext.connectionNr.   r   r.   rA   )r6   r7   r8   r9   propertyr@   rB   r1   r1   r1   r3   r=   G   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  r/   r0   r1   )r2   rK   rL   r1   r1   r3   __init__q       zDumper.__init__objr   r.   r:   c                 C  r>   )zlConvert the object `!obj` to PostgreSQL representation.

        :param obj: the object to convert.
        Nr1   r2   rP   r1   r1   r3   dumps      zDumper.dumpr   c                 C  r>   )ziConvert the object `!obj` to escaped representation.

        :param obj: the object to convert.
        Nr1   rQ   r1   r1   r3   quotez   rS   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()`.

        Nr1   r2   rP   rI   r1   r1   r3   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.
        Nr1   rU   r1   r1   r3   upgrade   s   zDumper.upgrader0   )rK   r   rL   rM   )rP   r   r.   r:   )rP   r   r.   r   )rP   r   rI   r   r.   r    rP   r   rI   r   r.   rG   )
r6   r7   r8   r9   __annotations__rN   rR   rT   rV   rW   r1   r1   r1   r3   rG   a   s   
 


$rG   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.
    rH   rI   NrJ   r+   rL   rM   c                 C  r/   r0   r1   )r2   rJ   rL   r1   r1   r3   rN      rO   zLoader.__init__datar   r.   r   c                 C  r>   )z|
        Convert the data returned by the database into a Python object.

        :param data: the data to convert.
        Nr1   )r2   r[   r1   r1   r3   load   rC   zLoader.loadr0   )rJ   r+   rL   rM   )r[   r   r.   r   )r6   r7   r8   r9   rY   rN   r\   r1   r1   r1   r3   rZ      s   
 rZ   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formatsNrL   rM   c                 C  r/   r0   r1   )r2   rL   r1   r1   r3   rN      rO   zTransformer.__init__r.   c                 C  r/   r0   r1   )rK   rL   r1   r1   r3   from_context      zTransformer.from_contextrA   c                 C  r/   r0   r1   r?   r1   r1   r3   rB      ra   zTransformer.connectionstrc                 C  r/   r0   r1   r?   r1   r1   r3   encoding   ra   zTransformer.encodingr   c                 C  r/   r0   r1   r?   r1   r1   r3   r@      ra   zTransformer.adaptersPGresult | Nonec                 C  r/   r0   r1   r?   r1   r1   r3   pgresult   ra   zTransformer.pgresultT)set_loadersrI   resultrf   boolrI   pq.Format | NoneNonec                C  r/   r0   r1   )r2   rg   rf   rI   r1   r1   r3   set_pgresult   rC   zTransformer.set_pgresultSequence[int]rH   c                 C  r/   r0   r1   r2   r^   rI   r1   r1   r3   set_dumper_types   rO   zTransformer.set_dumper_typesc                 C  r/   r0   r1   rm   r1   r1   r3   set_loader_types   rO   zTransformer.set_loader_typesparamsSequence[Any]Sequence[PyFormat]Sequence[Buffer | None]c                 C  r/   r0   r1   )r2   rp   r_   r1   r1   r3   dump_sequence   r5   zTransformer.dump_sequencerP   r   bytesc                 C  r/   r0   r1   rQ   r1   r1   r3   
as_literal   rO   zTransformer.as_literalr   rG   c                 C  r/   r0   r1   rU   r1   r1   r3   
get_dumper   rO   zTransformer.get_dumperrow0r+   row1make_rowRowMaker[Row]	list[Row]c                 C  r/   r0   r1   )r2   rx   ry   rz   r1   r1   r3   	load_rows   rO   zTransformer.load_rowsrow
Row | Nonec                 C  r/   r0   r1   )r2   r~   rz   r1   r1   r3   load_row   rO   zTransformer.load_rowrecordtuple[Any, ...]c                 C  r/   r0   r1   )r2   r   r1   r1   r3   load_sequence   rO   zTransformer.load_sequencerJ   rZ   c                 C  r/   r0   r1   )r2   rJ   rI   r1   r1   r3   
get_loader   rO   zTransformer.get_loaderr0   )rL   rM   )rL   rM   r.   r]   rE   )r.   rb   rD   )r.   rd   )rg   rd   rf   rh   rI   ri   r.   rj   )r^   rl   rI   rH   r.   rj   )rp   rq   r_   rr   r.   rs   )rP   r   r.   ru   rX   )rx   r+   ry   r+   rz   r{   r.   r|   )r~   r+   rz   r{   r.   r   )r   rs   r.   r   )rJ   r+   rI   rH   r.   rZ   )r6   r7   r8   rY   rN   classmethodr`   rF   rB   rc   r@   re   rk   rn   ro   rt   rv   rw   r}   r   r   r   r1   r1   r1   r3   r]      s4   
 







r]   )7r9   
__future__r   typingr   r   r   r   r   r   r	    r   _enumsr   _compatr   r   r   rowsr   r   pq.abcr   waitingr   r   r   _adapters_mapr   _connection_baser   r   r   rY   r   r   r   r   r   r    r!   r"   rb   r#   r$   r%   r&   r'   r;   r<   r=   rG   rZ   r]   r1   r1   r1   r3   <module>   sJ    S