Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.16.67.57
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : connection.cpython-310.pyc
o

�\�@�@s"dZzddlZdZWndZYddlZddlZddlmZddlmZddl	m
Z
mZmZdd	l
mZdd
lmZmZddlmZmZmZddlmZmZd
ZdZGdd�de�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de!�Z"Gdd�de!�Z#dS)z4Implementation of communication for MySQL X servers.�NTF��wraps�)�MySQL41AuthPlugin)�InterfaceError�OperationalError�ProgrammingError��Schema)�Protocol�MessageReaderWriter)�Result�	RowResult�	DocResult)�SqlStatement�AddStatementzDROP DATABASE IF EXISTS `{0}`z#CREATE DATABASE IF NOT EXISTS `{0}`c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zifdd�Zd
S)�SocketStreamcCsd|_d|_dS)NF)�_socket�_is_ssl��self�r�H/usr/local/python-3.10/lib/python3.10/site-packages/mysqlx/connection.py�__init__2s
zSocketStream.__init__cCs6t|t�rtjntj}t�|tj�|_|j�|�dS�N)�
isinstance�tuple�socket�AF_INET�AF_UNIX�SOCK_STREAMr�connect)r�paramsZs_typerrrr!6szSocketStream.connectcCsb|jdur	td��g}|dkr,|j�|�}|dkrtd��|�|�|t|�8}|dksd�|�S)N�MySQLx Connection not availabler�zUnexpected connection close)rr�recv�RuntimeError�append�len�join)r�count�buf�datarrr�read;s

�
zSocketStream.readcCs"|jdur	td��|j�|�dS)Nr#)rr�sendall�rr,rrrr.Gs
zSocketStream.sendallcCs|jsdS|j��d|_dSr)r�closerrrrr0Ls

zSocketStream.closec	Cs2ts
|��td��t�tj�}|��d|vr8z
|�|d�tj|_	Wnt
tjfy7|��td��wd|vr\z
|�|d�tj
|_Wnt
tjfy[|��td��wd|vr�z|�|d|�dd��Wq�t
tjfy�|��td��wd|vr�|��td	��|�|j�|_d
|_dS)Nz'Python installation has no SSL support.zssl-cazInvalid CA certificate.zssl-crlzInvalid CRL.zssl-certzssl-keyzInvalid Client Certificate/Key.z Client Certificate not provided.T)�
SSL_AVAILABLEr0r&�sslZ
SSLContextZPROTOCOL_SSLv23Zload_default_certsZload_verify_locationsZ
CERT_REQUIREDZverify_mode�IOErrorZSSLErrorrZVERIFY_CRL_CHECK_CHAINZverify_flagsZload_cert_chain�getZwrap_socketrr)rZssl_opts�contextrrr�set_sslSsF��

��
zSocketStream.set_sslN)	�__name__�
__module__�__qualname__rr!r-r.r0r6rrrrr1srcst���fdd��}|S)Nc	s>z�|g|�Ri|��WStjtfy|��td��w)NzCannot connect to host.)r�errorr&�
disconnectr)r�args�kwargs��funcrr�wrapperxs�z(catch_network_exception.<locals>.wrapperr)r?r@rr>r�catch_network_exceptionwsrAc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	d
d��Z
e	dd��Ze	dd��Ze	dd��Z
e	dd��Ze	d+dd��Ze	dd��Ze	dd��Ze	dd��Ze	d d!��Ze	d"d#��Zd$d%�Zd&d'�Zd(d)�Zd*S),�
ConnectioncCsH|�d�|_|�d�|_|�d�|_d|_||_t�|_d|_d|_	dS)N�user�password�schema)
r4�_user�	_passwordZ_schema�_active_result�settingsr�stream�
reader_writer�protocol�rrIrrrr�s
zConnection.__init__cCs"|jdur|j��d|_dSdSr)rH�	fetch_allrrrr�fetch_active_result�s


�zConnection.fetch_active_resultcCs:d|jvr|jd|j�dd�fSd|jvr|jdSdS)N�host�port�$�r)Z	localhostrR)rIr4rrrr�_connection_params�s



zConnection._connection_paramscCs<|j�|���t|j�|_t|j�|_|��|��dSr)	rJr!rSrrKrrL�_handle_capabilities�
_authenticaterrrrr!�s
zConnection.connectcCs�|j��j}|r|dj��dks$n	|j�dd�r"|��td��dSt	j
dkr:|j�dd�r8|��td��dS|jjdd	�|j
�|j�dS)
Nr�tlsFz
ssl-enablezSSL not enabled at server.)���	z=The support for SSL is not available for this Python version.T)rV)rLZget_capabilitesZcapabilities�name�lowerrIr4r0r�sys�version_infor&Zset_capabilitiesrJr6r/rrrrT�s
zConnection._handle_capabilitiescCsHt|j|j�}|j�|���|j��}|j�|�|��|j�	�dSr)
rrFrGrLZsend_auth_startZ	auth_nameZread_auth_continueZsend_auth_continueZbuild_authentication_responseZread_auth_ok)rZplugin�
extra_datarrrrU�s
�zConnection._authenticatecGs|j�d||�dS)N�sql)rL�send_execute_statement)rr_r<rrr�send_sql�szConnection.send_sqlcCs*|j�|�d}t|t�r|j}t||�Sr)rL�send_insertrrZ_idsr
)r�	statementZidsrrrrb�s


zConnection.send_insertcCs"|j�|�|jr
t|�St|�Sr)rLZ	send_findZ
_doc_basedrr�rrcrrr�find�szConnection.findcC�|j�|�t|�Sr)rLZsend_deleter
rdrrr�delete��zConnection.deletecCrfr)rLZsend_updater
rdrrr�update�rhzConnection.updateTcGs|j�|||�t|�Sr)rLr`r
)r�	namespace�cmdZ
raise_on_failr<rrr�execute_nonquery��zConnection.execute_nonquerycGs>|j�d||�t|�}|��|jdkrtd��|ddS)Nr_rz
No data found)rLr`rrNr*r)rr_r<�resultrrr�execute_sql_scalar�s
zConnection.execute_sql_scalarcGs|j�d||�t|�S)NZxplugin)rLr`r)rrkr<rrr�get_row_result�rmzConnection.get_row_resultcC�|j�|�Sr)rL�read_row�rrnrrrrr��zConnection.read_rowcC�|j�|�dSr)rL�close_resultrsrrrrv�szConnection.close_resultcCrqr)rL�get_column_metadatarsrrrrw�rtzConnection.get_column_metadatacCs|jjduSr)rJrrrrr�is_open�szConnection.is_opencCs|��sdS|j��dSr)rxrJr0rrrrr;�szConnection.disconnectcCsB|��sdS|jdur|j��|j��|j��|j��dSr)rxrHrNrLZ
send_close�read_okrJr0rrrrr0�s



zConnection.closeN)T)r7r8r9rrOrSr!rTrUrArarbrergrirlrorprrrvrwrxr;r0rrrrrB�s@










rBcs\eZdZ�fdd�Zdd�Z�fdd�Z�fdd�Zd	d
�Z�fdd�Z�fd
d�Z	�Z
S)�XConnectioncs�tt|��|�g|_|�dg�|_d|vr*|dr*|j�|�d�|�dd�d��d|_d|_|�	�|jj
dd�dd	�dS)
NZroutersrPrQ)rPrQ���TcSs|dS)N�priorityr)�xrrr�<lambda>sz&XConnection.__init__.<locals>.<lambda>)�key�reverse)�superrzr�dependent_connections�pop�_routersr'�_cur_router�
_can_failover�_ensure_priorities�sortrM��	__class__rrrs
�zXConnection.__init__cCs�d}d}|jD]"}|�dd�}|dur|d7}||d<n	|dkr%tdd��|d8}qd|kr7t|j�kr?ndStdd��dS)	Nr�dr|rz(The priorities must be between 0 and 100i�z\You must either assign no priority to any of the routers or give a priority for every routeri�)r�r4rr()rZpriority_countr|�routerZprirrrr�s"

�
 ��zXConnection._ensure_prioritiescs�|js
d|_tt|���S|jr|jdur%d|_d|_|jD]}d|d<q|jd7_|j|jd}|j|jd}|jdkrKd|j|jdd<|jt|j�dkrXd|_||fS)	NFr{TZ	availablerrPrQr)r�r�r�rzrSr�r()rr�rPrQr�rrrS)s 


zXConnection._connection_paramsc
srd}|jr&ztt|���WStjy"}z|}WYd}~nd}~ww|jst|j�dkr4td�	|���tdd��)Nr�Cannot connect to host: {0}z(Failed to connect to any of the routers.i�)
r�r�rzr!rr:r(r�r�format)rr:�errr�rrr!@s���
zXConnection.connectcCrur)r�r')rZ
connectionrrr�bind_connectionMszXConnection.bind_connectionc�,|jr
|j����|jstt|���dSr)r�r�r0r�rzrr�rrr0P��zXConnection.closecr�r)r�r�r;r�rzrr�rrr;Ur�zXConnection.disconnect)r7r8r9rr�rSr!r�r0r;�
__classcell__rrr�rrzs
rzcs(eZdZ�fdd�Z�fdd�Z�ZS)�NodeConnectioncstt|��|�dSr)r�r�rrMr�rrr\szNodeConnection.__init__c
s>z
tt|���WdStjy}ztd�|���d}~ww)Nr�)r�r�r!rr:rr�)rr�r�rrr!_s��zNodeConnection.connect)r7r8r9rr!r�rrr�rr�[sr�c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BaseSessiona�Base functionality for Session classes through the X Protocol.

    This class encloses the core functionality to be made available on both
    the XSession and NodeSession classes, such functionality includes:

        - Accessing available schemas.
        - Schema management operations.
        - Enabling/disabling warning generation.
        - Retrieval of connection information.

    Args:
        settings (dict): Connection data used to connect to the database.
    cCs
||_dSr)�	_settingsrMrrrrts
zBaseSession.__init__cCs|jjjduSr)�_connectionrJrrrrrrxw�zBaseSession.is_opencCs
t||�S)z�Retrieves a Schema object from the current session by it's name.

        Args:
            name (string): The name of the Schema object to be retrieved.

        Returns:
            mysqlx.Schema: The Schema object with the given name.
        r	�rrZrrr�
get_schemazs
	zBaseSession.get_schemacCs(|jj�d�rt||jjd�Std��)aKRetrieves a Schema object from the current session by the schema
        name configured in the connection settings.

        Returns:
            mysqlx.Schema: The Schema object with the given name at connect
                           time.

        Raises:
            ProgrammingError: If default schema not provided.
        rEzDefault schema not provided)r�rIr4r
rrrrr�get_default_schema�szBaseSession.get_default_schemacCs|j�dt�|�d�dS)z�Drops the schema with the specified name.

        Args:
            name (string): The name of the Schema object to be retrieved.
        r_TN)r�rl�_DROP_DATABASE_QUERYr�r�rrr�drop_schema�s�zBaseSession.drop_schemacCs |j�dt�|�d�t||�S)z�Creates a schema on the database and returns the corresponding
        object.

        Args:
            name (string): A string value indicating the schema name.
        r_T)r�rl�_CREATE_DATABASE_QUERYr�r
r�rrr�
create_schema�s�
zBaseSession.create_schemacC�|j�ddd�dS)z4Starts a transaction context on the server.
        r_zSTART TRANSACTIONTN�r�rlrrrr�start_transaction�szBaseSession.start_transactioncCr�)zXCommits all the operations executed after a call to
        startTransaction().
        r_ZCOMMITTNr�rrrr�commit��zBaseSession.commitcCr�)zYDiscards all the operations executed after a call to
        startTransaction().
        r_ZROLLBACKTNr�rrrr�rollback�r�zBaseSession.rollbackcCs|j��dSr)r�r0rrrrr0�r�zBaseSession.closeN)r7r8r9�__doc__rrxr�r�r�r�r�r�r�r0rrrrr�fs
	r�c�(eZdZdZ�fdd�Zdd�Z�ZS)�XSessionaWEnables interaction with a X Protocol enabled MySQL Product.

    The functionality includes:

    - Accessing available schemas.
    - Schema management operations.
    - Enabling/disabling warning generation.
    - Retrieval of connection information.

    Args:
        settings (dict): Connection data used to connect to the database.
    c�*tt|��|�t|j�|_|j��dSr)r�r�rrzr�r�r!rMr�rrr��zXSession.__init__cCs,|��std��t|j�}|j�|j�|S)Nz$XSession is not connected to a farm.)rxr�NodeSessionr�r�r�)rZnsessrrr�bind_to_default_shard�s

zXSession.bind_to_default_shard)r7r8r9r�rr�r�rrr�rr��sr�cr�)r�atEnables interaction with a X Protocol enabled MySQL Server.

    The functionality includes:

    - Accessing available schemas.
    - Schema management operations.
    - Enabling/disabling warning generation.
    - Retrieval of connection information.
    - Includes SQL Execution.

    Args:
        settings (dict): Connection data used to connect to the database.
    cr�r)r�r�rr�r�r�r!rMr�rrr�r�zNodeSession.__init__cCst|j|�S)z}Creates a :class:`mysqlx.SqlStatement` object to allow running the
        SQL statement on the target MySQL Server.
        )rr�)rr_rrrr_�szNodeSession.sql)r7r8r9r�rr_r�rrr�rr��s
r�)$r�r2r1r\r�	functoolsrZauthenticationr�errorsrrrZcrudr
rLrrrnr
rrrcrrr�r��objectrrArBrzr�r�r�r�rrrr�<module>s4FUW
© 2025 GrazzMean