U
    Ú²gv  ã                   @  s`  d 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 ddlmZ dd	l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r¼ddlmZ ddlmZ ddlmZ G dd„ deƒ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"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 raw queries cursors
é    )Úannotations)ÚTYPE_CHECKINGé   )ÚConnectionTypeÚQueryÚParams)Ú
Composable)ÚRow)ÚPyFormat)ÚCursor)ÚAsyncCursor)ÚServerCursorÚAsyncServerCursor)ÚPostgresQuery)Ú
BaseCursor)ÚAny)Ú
Connection)ÚAsyncConnectionc                   @  s.   e Zd Zddddœdd„Zdddœdd	„Zd
S )ÚPostgresRawQueryr   zParams | NoneÚNone)ÚqueryÚvarsÚreturnc                 C  sT   t |tƒr| | j¡}nt |tƒr0| | j¡}n|}|| _d  | _| _	|  
|¡ d S )N)Ú
isinstanceÚstrÚencodeÚ	_encodingr   Úas_bytesÚ_txr   Ú_want_formatsÚ_orderÚdump)Úselfr   r   Úbquery© r$   ú6/tmp/pip-unpacked-wheel-b_ea6rx_/psycopg/raw_cursor.pyÚconvert   s    

zPostgresRawQuery.convert)r   r   c                 C  sn   |d k	rXt  |¡stdƒ‚tjgt|ƒ | _| j || j¡| _	| jj
pHd| _
| jj| _nd | _	d| _
d | _d S )Nz,raw queries require a sequence of parametersr$   )r   Zis_params_sequenceÚ	TypeErrorr
   ZAUTOÚlenr   r   Zdump_sequenceÚparamsÚtypesÚformats)r"   r   r$   r$   r%   r!   '   s    
zPostgresRawQuery.dumpN)Ú__name__Ú
__module__Ú__qualname__r&   r!   r$   r$   r$   r%   r      s   r   c                   @  s   e Zd ZeZdS )ÚRawCursorMixinN)r,   r-   r.   r   Z
_query_clsr$   r$   r$   r%   r/   6   s   r/   c                   @  s   e Zd ZdZdS )Ú	RawCursorÚpsycopgN©r,   r-   r.   r$   r$   r$   r%   r0   :   s   r0   zConnection[Any]c                   @  s   e Zd ZdZdS )ÚAsyncRawCursorr1   Nr2   r$   r$   r$   r%   r3   >   s   r3   zAsyncConnection[Any]c                   @  s   e Zd ZdZdS )ÚRawServerCursorr1   Nr2   r$   r$   r$   r%   r4   B   s   r4   c                   @  s   e Zd ZdZdS )ÚAsyncRawServerCursorr1   Nr2   r$   r$   r$   r%   r5   F   s   r5   N)%Ú__doc__Ú
__future__r   Útypingr   Úabcr   r   r   Zsqlr   Zrowsr	   Z_enumsr
   Úcursorr   Zcursor_asyncr   Zserver_cursorr   r   Z_queriesr   Z_cursor_baser   r   Ú
connectionr   Zconnection_asyncr   r   r/   r0   r3   r4   r5   r$   r$   r$   r%   Ú<module>   s0   

 ÿ