o
    á6	fÿ
  ã                   @   s0  d Z ddlmZ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 dd	lmZ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rdddlmZ ddlmZ ddlm Z  ej!j"Z"ej!j#Z#G dd„ deeef ƒZ$G dd„ de$def ee ƒZ%G dd„ de$def ee ƒZ&dS )z%
psycopg client-side binding cursors
é    )ÚOptionalÚTupleÚTYPE_CHECKING)Úpartialé   )ÚPostgresQueryÚPostgresClientQuery)Úpq)Úadapt)Úerrors)ÚConnectionTypeÚQueryÚParams)ÚRow)Ú
BaseCursorÚCursor)ÚPrepare)ÚAsyncCursor)ÚAny)Ú
Connection)ÚAsyncConnectionc                	   @   s’   e Zd Zddedee defdd„Zdddœded	e	d
ee	 ddfdd„Z
	ddedee defdd„Z	ddedee	 deeef fdd„ZdS )ÚClientCursorMixinNÚqueryÚparamsÚreturnc                 C   s(   t  | ¡| _|  ||¡}|j | jj¡S )z£
        Return the query and parameters merged.

        Parameters are adapted and merged to the query the same way that
        `!execute()` would do.

        )r
   ÚTransformerÚ_txÚ_convert_queryr   ÚdecodeÚencoding©Úselfr   r   Úpgq© r#   úN/home/ertert/spirit/venv/lib/python3.10/site-packages/psycopg/client_cursor.pyÚmogrify   s   zClientCursorMixin.mogrifyF)Úforce_extendedÚbinaryr&   r'   c                C   sˆ   |d u r| j }n|rtnt}|tkrt d¡‚|| _| jjr/| jjj 	t
| jj|jd ƒ¡ d S |r;| j |jd ¡ d S | j |j¡ d S )Nz0client-side cursors don't support binary results)ÚformatÚBINARYÚTEXTÚeÚNotSupportedErrorÚ_queryÚ_connÚ	_pipelineÚcommand_queueÚappendr   Ú_pgconnÚsend_query_paramsr   Ú
send_query)r!   r   r&   r'   Úfmtr#   r#   r$   Ú_execute_send+   s   ÿ
ÿzClientCursorMixin._execute_sendc                 C   s   t | jƒ}| ||¡ |S ©N)r   r   Úconvertr    r#   r#   r$   r   K   s   
z ClientCursorMixin._convert_queryr"   Úpreparec                 C   s
   t jdfS )Nó    )r   ÚNO)r!   r"   r9   r#   r#   r$   Ú_get_preparedR   s   
zClientCursorMixin._get_preparedr7   )Ú__name__Ú
__module__Ú__qualname__r   r   r   Ústrr%   r   Úboolr6   r   r   r   Úbytesr<   r#   r#   r#   r$   r      s:    ûþüû
ú!ÿÿÿ
þÿÿÿ
þr   c                   @   ó   e Zd ZdZdS )ÚClientCursorÚpsycopgN©r=   r>   r?   r#   r#   r#   r$   rD   X   s    rD   zConnection[Any]c                   @   rC   )ÚAsyncClientCursorrE   NrF   r#   r#   r#   r$   rG   \   s    rG   zAsyncConnection[Any]N)'Ú__doc__Útypingr   r   r   Ú	functoolsr   Ú_queriesr   r   Ú r	   r
   r   r+   Úabcr   r   r   Úrowsr   Úcursorr   r   Ú
_preparingr   Úcursor_asyncr   r   Ú
connectionr   Úconnection_asyncr   ÚFormatr*   r)   r   rD   rG   r#   r#   r#   r$   Ú<module>   s.    :
ÿ