File: //var/opt/nydus/ops/mysql/connector/__pycache__/connection_cext.cpython-39.pyc
a
�,�h� �
@ s� d Z ddlZddlZddlZddlZddlmZmZmZm Z m
Z
mZmZm
Z
mZmZ ddlmZ ddlmZmZ ddlmZmZmZmZmZ ddlmZ dd lmZmZm Z m!Z!m"Z" dd
l#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, ddl-m.Z.m/Z/m0Z0 d
Z1zTddl2Z2ddl2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ dZ1W n8 eA�y� ZB zeAdeB� d��eB�W Y dZB[Bn
dZB[B0 0 ddlCmDZD ddlEmFZF eD�r�ddlGmHZHmIZI G dd� de�ZJdS )z'Connection class using the C Extension.� N)
�Any�BinaryIO�Dict�List�NoReturn�Optional�Sequence�Tuple�Type�Union� )�version)�CMySQLPrepStmt�MySQLConnectionAbstract)�
ClientFlag� FieldFlag� FieldType�
ServerFlag�ShutdownType)�MySQLConverter)�InterfaceError�
InternalError�OperationalError�ProgrammingError�get_mysql_exception)�
MySQLProtocol)�CextEofPacketType�CextResultType�DescriptionType�ParamsSequenceOrDictType�RowType�StatsPacketType�
StrOrBytes)�
import_object�warn_ciphersuites_deprecated�warn_tls_version_deprecatedF)�MySQLInterfaceError)�CMySQLCursor�CMySQLCursorBuffered�CMySQLCursorBufferedDict�CMySQLCursorBufferedNamedTuple�CMySQLCursorBufferedRaw�CMySQLCursorDict�CMySQLCursorNamedTuple�CMySQLCursorPrepared�CMySQLCursorPreparedDict�CMySQLCursorPreparedNamedTuple�CMySQLCursorPreparedRaw�CMySQLCursorRawTz2MySQL Connector/Python C Extension not available (�))�OTEL_ENABLED)�with_context_propagation)�end_span�record_exception_eventc s� e Zd ZdZedd�� fdd�Zdd�dd�Zdd�d d
�Zee d�dd��Z
edd
�dd�Zd�e
dd�dd�Zee
d�dd��Zeje
dd�dd��Zeed�dd��Zejedd�dd��Zee
d�dd��Zdd�dd�Zdd�dd�ZeZe
d�d d!�Ze
d�d"d#�Zd�e
e e dd'�d(d)�Zedd*�d+d,�Zeee d-�d.d/�Zeee d�d0d1��Zd�ee e
eee ee
ee! e"ee ee# f d2�d3d4�Z$d�e
eee ee
ee! e"ee ee# f d5�d6d7�Z%ee
d�d8d9�Z&dd�d:d;�Z'dd�d<d=�Z(dd�d>d?�Z)edd@�dAdB�Z*d�ee! e+dC�dDdE�Z,ee# d�dFdG�Z-e.e!dH�dIdJ�Z/e0e!eee1e#e+f dK�dLdM��Z2e!ddN�dOdP�Z3e!ddN�dQdR�Z4e0d�eee
e
e
ee1e#e+f dS�dTdU��Z5e5Z6d�ee
ee
ee
ee7e8 ee
ee
e8dV�dWdX�Z9ee d�dYdZ��Z:ee d�d[d\��Z;ee
d�d]d^��Z<ee
d�d_d`��Z=ee
d�dadb��Z>e?e1e@e. eAee.f f dc�ddde�ZBdd�dfdg�ZCd�eeee eeeee ee ddj�
dkdl�ZDe
d�dmdn�ZEe ee# do�dpdq�ZFdd�drds�ZGd�ee ddt�dudv�ZHeId�dwdx�ZJe ddy�dzd{�ZKeLd�d|d}�ZMeLd�d~d�ZNeeLd��d�d��ZOe!e ePeLd��d�d��ZQd�e
dd��d�d��ZRd�eeAeef eeAeef dd��d�d��ZS� ZTS )��CMySQLConnectionz6Class initiating a MySQL Connection using Connector/C.N)�kwargs�returnc s� t std��d| _g | _tj�tj�tj�t j
��ddd�| _t�
� dkrntj�| j�sntj�d�rhdnd| _d| _t� �� |r�z| jf i |�� W n ty� | �� � Y n0 dS ) ZInitializationz0MySQL Connector/Python C Extension not availableNZmysql�vendorZplugin�Linuxz/usr/lib64/mysql/pluginz/usr/lib/mysql/plugin)�HAVE_CMYSQL�RuntimeError�_cmysql�_columns�os�path�join�dirname�abspath�_mysql_connector�__file__�_plugin_dir�platform�system�exists� converter�super�__init__�connect� Exception�close)�selfr9 �� __class__� �R/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/connector/connection_cext.pyrN t s2 ��
��
zCMySQLConnection.__init__)r: c
C sZ t j�d�}|d dkrd}nd}| j�d|d�dd � t jdd
� D ��t�� d�� dS )
z!Add default connection attributes� r ZGPLv2zGPL-2.0Z
Commercialzmysql-connector-python�.c S s g | ]}t |��qS rU )�str)�.0�xrU rU rV �
<listcomp>� � z<CMySQLConnection._add_default_conn_attrs.<locals>.<listcomp>� )Z_connector_nameZ_connector_licenseZ_connector_versionZ_source_hostN) r
ZLICENSE�split�_conn_attrs�updaterC �VERSION�socket�gethostname)rR Zlicense_chunksZclient_licenserU rU rV �_add_default_conn_attrs� s ��z(CMySQLConnection._add_default_conn_attrsc C sT | j �� | j �� | j �� dddd| j �� d�| _| �| jd �| _| j� | j� dS )z<Gather information of the MySQL server before authenticationN)�protocol�server_version_originalZserver_threadid�charset�
server_status�auth_pluginZ auth_dataZcapabilitiesrg )
r? Zget_proto_infoZget_server_info� thread_idZst_server_capabilitiesZ
_handshakeZ_check_server_versionZ_server_version�_character_setZset_mysql_version�rR rU rU rV �
_do_handshake� s ��zCMySQLConnection._do_handshakec C s
| j �� S )z6Returns the server status attribute of MYSQL structure)r? Zst_server_statusrm rU rU rV �_server_status� s zCMySQLConnection._server_status)rB r: c C s | j r| j �|� dS )zJset local_infile_in_path
Set allow_local_infile_in_path.
N)r? Z!set_load_data_local_infile_option)rR rB rU rU rV �set_allow_local_infile_in_path� s z/CMySQLConnection.set_allow_local_infile_in_pathT)�valuer: c C s. || _ | jr| j�|� | jr*| j�|� dS )zuToggle unicode mode
Set whether we return string fields as unicode or not.
Default is True.
N)�_use_unicoder? �use_unicoderL �set_unicode�rR rq rU rU rV rt � s
zCMySQLConnection.set_unicodec C s | � d�d }|dkS )z#Get whether autocommit is on or offzSELECT @@session.autocommitr r ��
info_queryru rU rU rV �
autocommit� s zCMySQLConnection.autocommitc
C sV z| j �|� || _W n: tyP } z"t|j|j|jd�|�W Y d}~n
d}~0 0 dS )zToggle autocommit��msg�errno�sqlstateN)r? rx Z_autocommitr&