Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/__pycache__/pg8000.cpython-311.pyc

�

�܋f�%����dZddlZddlZddlmZddlmZddlmZddlmZddlmZdd	lm	Z	dd
lm
Z
ddlmZddlm
Z
d
dlmZd
dlmZd
dlmZd
dlmZd
dlmZ	ddlmZn
#e$rdZYnwxYwGd�dej��ZGd�de��ZGd�de
��ZGd�de��ZGd�de	��ZGd�de��ZGd�d e
��Z Gd!�d"e��Z!e!Z"dS)#a�
.. dialect:: postgresql+pg8000
    :name: pg8000
    :dbapi: pg8000
    :connectstring: postgresql+pg8000://user:password@host:port/dbname[?key=value&key=value...]
    :url: https://pythonhosted.org/pg8000/

.. note::

    The pg8000 dialect is **not tested as part of SQLAlchemy's continuous
    integration** and may have unresolved issues.  The recommended PostgreSQL
    dialect is psycopg2.

.. _pg8000_unicode:

Unicode
-------

pg8000 will encode / decode string values between it and the server using the
PostgreSQL ``client_encoding`` parameter; by default this is the value in
the ``postgresql.conf`` file, which often defaults to ``SQL_ASCII``.
Typically, this can be changed to ``utf-8``, as a more useful default::

    #client_encoding = sql_ascii # actually, defaults to database
                                 # encoding
    client_encoding = utf8

The ``client_encoding`` can be overridden for a session by executing the SQL:

SET CLIENT_ENCODING TO 'utf8';

SQLAlchemy will execute this SQL on all new connections based on the value
passed to :func:`_sa.create_engine` using the ``client_encoding`` parameter::

    engine = create_engine(
        "postgresql+pg8000://user:pass@host/dbname", client_encoding='utf8')


.. _pg8000_isolation_level:

pg8000 Transaction Isolation Level
-------------------------------------

The pg8000 dialect offers the same isolation level settings as that
of the :ref:`psycopg2 <psycopg2_isolation_level>` dialect:

* ``READ COMMITTED``
* ``READ UNCOMMITTED``
* ``REPEATABLE READ``
* ``SERIALIZABLE``
* ``AUTOCOMMIT``

.. versionadded:: 0.9.5 support for AUTOCOMMIT isolation level when using
   pg8000.

.. seealso::

    :ref:`postgresql_isolation_level`

    :ref:`psycopg2_isolation_level`


�N�)�_DECIMAL_TYPES)�_FLOAT_TYPES)�
_INT_TYPES)�
PGCompiler)�	PGDialect)�PGExecutionContext)�PGIdentifierPreparer)�UUID)�JSON�)�exc)�
processors)�types)�util)�quoted_namec��eZdZd�ZdS)�
_PGNumericc�@�|jrX|tvr$tjtj|j��S|tvs	|tvrdStj
d|z���|tvrdS|tvs	|tvrtjStj
d|z���)NzUnknown PG numeric type: %d)�	asdecimalrr�to_decimal_processor_factory�decimal�Decimal�_effective_decimal_return_scalerrr�InvalidRequestError�to_float)�self�dialect�coltypes   �\/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/dialects/postgresql/pg8000.py�result_processorz_PGNumeric.result_processor`s����>�	��,�&�&�!�>��O�T�%I�����N�*�*�g��.C�.C��t��-�1�G�;�����,�&�&��t��N�*�*�g��.C�.C�!�*�*��-�1�G�;����N)�__name__�
__module__�__qualname__r!�r"r rr_s#����������r"rc��eZdZd�ZdS)�_PGNumericNoBindc��dS�Nr&)rrs  r �bind_processorz_PGNumericNoBind.bind_processorzs���tr"N)r#r$r%r+r&r"r r(r(ys#����������r"r(c���eZdZ�fd�Z�xZS)�_PGJSONc�p��|jdkrdStt|���||��S)N)r�
r)�_dbapi_version�superr-r!)rrr�	__class__s   �r r!z_PGJSON.result_processors6����!�J�.�.��4���$�'�'�8�8��'�J�J�Jr")r#r$r%r!�
__classcell__�r2s@r r-r-~sA�������K�K�K�K�K�K�K�K�Kr"r-c��eZdZd�Zd�ZdS)�_PGUUIDc��|jsd�}|SdS)Nc�(�|�t|��}|Sr*)�_python_UUID��values r �processz'_PGUUID.bind_processor.<locals>.process�s���$�(��/�/�E��r"��as_uuid)rrr<s   r r+z_PGUUID.bind_processor��,���|�	�
�
�
�
�N�	�	r"c��|jsd�}|SdS)Nc�(�|�t|��}|Sr*��strr:s r r<z)_PGUUID.result_processor.<locals>.process�s���$���J�J�E��r"r=)rrrr<s    r r!z_PGUUID.result_processor�r?r"N)r#r$r%r+r!r&r"r r6r6�s2�������������r"r6c��eZdZdS)�PGExecutionContext_pg8000N)r#r$r%r&r"r rErE�s�������Dr"rEc��eZdZd�Zd�ZdS)�PGCompiler_pg8000c�V�|j|jfi|��dz|j|jfi|��zS)Nz %% )r<�left�right)r�binary�operator�kws    r �visit_mod_binaryz"PGCompiler_pg8000.visit_mod_binary�sF���D�L���+�+��+�+��
��d�l�6�<�.�.�2�.�.�
/�	
r"c�^�d|vrtjd��|�dd��S)N�%%z^The SQLAlchemy postgresql dialect now automatically escapes '%' in text() expressions to '%%'.�%)r�warn�replace)r�texts  r �post_process_textz#PGCompiler_pg8000.post_process_text�s:���4�<�<��I�'�
�
�
�
�|�|�C��&�&�&r"N)r#r$r%rNrUr&r"r rGrG�s2������
�
�
�'�'�'�'�'r"rGc��eZdZd�ZdS)�PGIdentifierPreparer_pg8000c�n�|�|j|j��}|�dd��S)NrQrP)rS�escape_quote�escape_to_quote)rr;s  r �_escape_identifierz.PGIdentifierPreparer_pg8000._escape_identifier�s/���
�
�d�/��1E�F�F���}�}�S�$�'�'�'r"N)r#r$r%r[r&r"r rWrW�s#������(�(�(�(�(r"rWc
�"��eZdZdZdZdZdZdZeZ	e
ZeZ
dZejejejeejeeeejeeei��Zdd�Z�fd�Zejd���Ze d	���Z!d
�Z"d�Z#d�Z$d
�Z%d�Z&d�Z'	dd�Z(	dd�Z)d�Z*d�Z+�xZ,S)�PGDialect_pg8000�pg8000T�format�use_encodingNc�8�tj|fi|��||_dSr*)r�__init__�client_encoding)rrc�kwargss   r rbzPGDialect_pg8000.__init__�s)����4�*�*�6�*�*�*�.����r"c�x��|jdk|_tt|���|��dS)N)r�	�)r0�supports_sane_multi_rowcountr1r]�
initialize)r�
connectionr2s  �r rizPGDialect_pg8000.initialize�s8���,0�,?�:�,M��)�
���%�%�0�0��<�<�<�<�<r"c��|jrKt|jd��r6td�tjd|jj��D����SdS)N�__version__c�,�g|]}t|����Sr&)�int)�.0�xs  r �
<listcomp>z3PGDialect_pg8000._dbapi_version.<locals>.<listcomp>�s.��������F�F���r"z(\d+)(?:[-\.]?|$))�crrrr)�dbapi�hasattr�tuple�re�findallrl)rs r r0zPGDialect_pg8000._dbapi_version�sj���:�
	 �'�$�*�m�<�<�
	 �����Z�,�d�j�.D��������
� �<r"c� �td��S)Nr^)�
__import__)�clss r rszPGDialect_pg8000.dbapi�s���(�#�#�#r"c��|�d���}d|vrt|d��|d<|�|j��g|fS)N�user)�username�port)�translate_connect_argsrn�update�query)r�url�optss   r �create_connect_argsz$PGDialect_pg8000.create_connect_args�sT���)�)�6�)�:�:���T�>�>��t�F�|�,�,�D��L����C�I�����D�z�r"c�$�dt|��vS)Nzconnection is closedrB)r�erj�cursors    r �
is_disconnectzPGDialect_pg8000.is_disconnect�s��%��Q���/�/r"c
��|�dd��}t|d��r|j}|dkr	d|_dS||jvr^d|_|���}|�d|z��|�d��|���dStj	d	|�d
|j
�dd�|j���d
����)N�_� rj�
AUTOCOMMITTFz=SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL %s�COMMITzInvalid value 'z2' for isolation_level. Valid isolation levels for z are z, z or AUTOCOMMIT)rSrtrj�
autocommit�_isolation_lookupr��execute�closer�
ArgumentError�name�join)rrj�levelr�s    r �set_isolation_levelz$PGDialect_pg8000.set_isolation_level�s����
�
�c�3�'�'���:�|�,�,�	/�#�.�J��L� � �$(�J�!�!�!�
�d�,�
,�
,�$)�J�!��&�&�(�(�F��N�N�%�',�-�
�
�
�
�N�N�8�$�$�$��L�L�N�N�N�N�N��#�#��5�5�$�)�)�)�T�Y�Y�t�/E�%F�%F�%F�%F�H���
r"c���t|d��r|j}|���}|�d|zdz��|�d��|���dS)NrjzSET CLIENT_ENCODING TO '�'r�)rtrjr�r�r�)rrjrcr�s    r �set_client_encodingz$PGDialect_pg8000.set_client_encodingsm���:�|�,�,�	/�#�.�J��"�"�$�$�����1�O�C�c�I�J�J�J����x� � � ��������r"c�@�|j�d|df��dS�Nr�)rj�	tpc_begin�rrj�xids   r �do_begin_twophasez"PGDialect_pg8000.do_begin_twophases%����'�'��C���5�5�5�5�5r"c�8�|j���dSr*)rj�tpc_preparer�s   r �do_prepare_twophasez$PGDialect_pg8000.do_prepare_twophases����)�)�+�+�+�+�+r"Fc�@�|j�d|df��dSr�)rj�tpc_rollback�rrjr��is_prepared�recovers     r �do_rollback_twophasez%PGDialect_pg8000.do_rollback_twophases'��	��*�*�A�s�B�<�8�8�8�8�8r"c�@�|j�d|df��dSr�)rj�
tpc_commitr�s     r �do_commit_twophasez#PGDialect_pg8000.do_commit_twophase#s'��	��(�(�!�S�"��6�6�6�6�6r"c�H�d�|j���D��S)Nc��g|]
}|d��S)rr&)ro�rows  r rqz8PGDialect_pg8000.do_recover_twophase.<locals>.<listcomp>)s��F�F�F�3��A��F�F�Fr")rj�tpc_recover)rrjs  r �do_recover_twophasez$PGDialect_pg8000.do_recover_twophase(s%��F�F�*�"7�"C�"C�"E�"E�F�F�F�Fr"c����g�d�}��|���j��fd�}��|���j��fd�}��|��t���dkr�fd�}|SdS)Nc�N�|jtj|jt<dSr*)�py_typesr�	text_typer)�conns r �
on_connectz/PGDialect_pg8000.on_connect.<locals>.on_connect.s��)-��t�~�)F�D�M�+�&�&�&r"c�>����|�j��dSr*)r�rc�r�rs �r r�z/PGDialect_pg8000.on_connect.<locals>.on_connect5�"����(�(��t�/C�D�D�D�D�Dr"c�>����|�j��dSr*)r��isolation_levelr�s �r r�z/PGDialect_pg8000.on_connect.<locals>.on_connect<r�r"rc�(���D]
}||���dSr*r&)r��fn�fnss  �r r�z/PGDialect_pg8000.on_connect.<locals>.on_connectCs+������B��B�t�H�H�H�H��r")�appendrcr��len)rr�r�s` @r r�zPGDialect_pg8000.on_connect+s�������	G�	G�	G�	�
�
�:������+�
E�
E�
E�
E�
E�
�J�J�z�"�"�"���+�
E�
E�
E�
E�
E�
�J�J�z�"�"�"��s�8�8�a�<�<�
�
�
�
�
����4r"r*)TF)-r#r$r%�driver�supports_unicode_statements�supports_unicode_binds�default_paramstylerhrE�execution_ctx_clsrG�statement_compilerrW�preparer�description_encodingr�update_copyr�colspecs�sqltypes�Numericr(�Floatrrr-rr6rbri�memoized_propertyr0�classmethodrsr�r�r�r�r�r�r�r�r�r�r3r4s@r r]r]�s��������
�F�"&��!��!��#'� �1��*��*�H�)���t������.��N�J��'��M�7��'�	
�	�	�H�/�/�/�/�=�=�=�=�=�
�� � ��� ��$�$��[�$����0�0�0����2���6�6�6�,�,�,�:?�9�9�9�9�:?�7�7�7�7�
G�G�G�������r"r])#�__doc__rrv�baserrrrrr	r
r�jsonrr�rrrr�r�sql.elementsr�uuidr9�ImportErrorr�rr(r-r6rErGrWr]rr&r"r �<module>r�s���>�>�~����	�	�	�	� � � � � � �������������������������$�$�$�$�$�$�&�&�&�&�&�&�������������������������!�!�!�!�!�!�������'�'�'�'�'�'��)�)�)�)�)�)�)�������L�L�L�����������!����4�����z����
K�K�K�K�K�d�K�K�K������d����,	�	�	�	�	� 2�	�	�	�'�'�'�'�'�
�'�'�'�$(�(�(�(�(�"6�(�(�(�Q�Q�Q�Q�Q�y�Q�Q�Q�h���s� A'�'A1�0A1

Hacked By AnonymousFox1.0, Coded By AnonymousFox