?????????? ????????? - ??????????????? - /home/agenciai/.local/lib/python3.9/site-packages/mysql/connector/__pycache__/connection.cpython-39.pyc
???????
a ��Jh�� � @ s@ d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl Z ddl mZ ddlm Z ddlmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ dd lmZmZ dd l m!Z! ddl"m#Z# ddl$m%Z%m&Z& dd l'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZD ddlEmEZE ddlFmGZGmHZHmIZI ddlJmKZK ddlLmMZM ddlNmOZOmPZPmQZQmRZRmSZS ddlTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z] ddl^m_Z_m`Z`maZambZbmcZcmdZd e�rddl"meZe eK�r,ddlfmgZgmhZh G dd� de#�ZidS )z.Implementing communication with MySQL servers.� )�annotationsN)�Decimal)�IOBase)� TYPE_CHECKING�Any�BinaryIO�Dict� Generator�List�Mapping�Optional�Sequence�Tuple�Type�Union� )�version)�cmd_refresh_verify_options�handle_read_write_timeout)�get_local_infile_filenames)�MySQLConnectionAbstract)�MySQLAuthenticator�get_auth_plugin)� ClientFlag� FieldType� RefreshOption� ServerCmd� ServerFlag�flag_is_set)�MySQLConverter)�MySQLCursor�MySQLCursorBuffered�MySQLCursorBufferedDict�MySQLCursorBufferedRaw�MySQLCursorDict�MySQLCursorPrepared�MySQLCursorPreparedDict�MySQLCursorRaw)�ConnectionTimeoutError� DatabaseError�Error�InterfaceError� InternalError�NotSupportedError�OperationalError�ProgrammingError�ReadTimeoutError�WriteTimeoutError� get_exception)�logger)�MySQLSocket�MySQLTCPSocket�MySQLUnixSocket)�OTEL_ENABLED)�with_context_propagation)� EOF_STATUS� ERR_STATUS�LOCAL_INFILE_STATUS� OK_STATUS� MySQLProtocol) �BinaryProtocolType�DescriptionType� EofPacketType� HandShakeType�OkPacketType� ResultType�RowType�StatsPacketType� StrOrBytes)�get_platform� int1store� int4store�lc_int�warn_ciphersuites_deprecated�warn_tls_version_deprecated)�CMySQLPrepStmt)�end_span�record_exception_eventc sP e Zd ZdZddd�� fdd�Zdd�dd �Zdd�d d�Zd�dddddddd�dd�Zdd�dd�Zdd�dd�Z dd�dd�Z dd�dd�ZeZe � d�dd dd ddd!d!d"d#� d$d%��Ze � d�d'dd!d!d(d)�d*d+��Zddd,�d-d.�Zedd�d/d0��Zd1d2d3�d4d5�Zd1d6d3�d7d8�Ze � d�d9d!d!d2d:�d;d<��Ze � d�d1d!d!d=d>�d?d@��Zd�ddAdBdCddDdE�dFdG�Ze � d�d!ddAdBdCddHdI�dJdK��Zdd�dLdM�Zd9d2dN�dOdP�Zee � d�dQddddd=dR�dSdT���Ze � dQddUdV�dWdX��Ze� dd2dY�dZd[��Zd1d�d\d]�Z d�d!dd^�d_d`�Z!e � dad�dbdc��Z"dd2dd�dedf�Z#d6d�dgdh�Z$d2d�didj�Z%e � d�d9d9d9d!d9d9d9d9d9d9dldm�dndo��Z&ed9d�dpdq��Z'e'j(d9ddr�dsdq��Z'dd�dtdu�Z)d9ddv�dwdx�Z*e+j,j(dddr�dydz��Z,d�d{d{dd|�d}d~�Z-d�ddddd��d�d��Z.ed!d�d�d���Z/d�dBdBdBd�dBd!d!d�d��d�d��Z0dd�d�d��Z1dd�d�d��Z2d9dd��d�d��Z3d9d�d��d�d��Z4d1d�d3�d�d��Z5e � d�d1d!d�d��d�d���Z6d�ddddd��d�d��Z7e � d1dd�d��d�d���Z8ed�dd�d�ddd�d��d�d���Z9dddd��d�d��Z:ddd'ddd��d�d��Z;dddd��d�d��Z<dd�d�d��Z=dd�d�d��Z>� Z?S )��MySQLConnectionzConnection to a MySQL Serverr �None)�kwargs�returnc s& d | _ d | _d | _t� �� t| _t�� | _ d | _ d | _d| _d| _ d| _d| _d| _d| _d | _d| _d| _i | _d| _d| _d| _d| _d| _d| _d| _d| _d| _d | _d| _ d | _!d | _"d | _#d| _$g | _%d| _&t'� | _(|�r"z| j)f i |�� W n$ t*�y | �+� d | _� Y n0 d S )NF� z 127.0.0.1i� r Tr ),� _protocol�_socket� _handshake�super�__init__r �_converter_classr �get_default� _client_flagsZ _sql_modeZ _time_zoneZ_autocommit�_user� _password� _databaseZ_hostZ_port�_unix_socketZ_client_hostZ_client_port�_ssl�_force_ipv6�_use_unicodeZ _get_warningsZ_raise_on_warnings� _bufferedZ_unread_result�_have_next_result�_raw�_in_transactionZ_prepared_statements�_ssl_active�_auth_plugin�_krb_service_principalZ_pool_config_version�_query_attrs_supported� _columns_desc�_mfa_nfactorr �_authenticator�connect� Exception�close)�selfrR �� __class__� �O/home/agenciai/.local/lib/python3.9/site-packages/mysql/connector/connection.pyrY � sV zMySQLConnection.__init__)rS c C sz t � }tj�d�}|d dkr$d}nd}tt�� �|d t�� d|d� d d � tj dd� D ��|d d �}| j�|� dS )z&Add the default connection attributes.� r ZGPLv2zGPL-2.0Z Commercial�archzmysql-connector-python�.c S s g | ]}t |��qS ru )�str)�.0�xru ru rv � <listcomp>� � z;MySQLConnection._add_default_conn_attrs.<locals>.<listcomp>� r )�_pid� _platformZ_source_hostZ_client_nameZ_client_licenseZ_client_version�_osN) rG r �LICENSE�splitrz �os�getpid�socket�gethostname�join�VERSION�_conn_attrs�update)rr �platformZlicense_chunksZclient_licenseZdefault_conn_attrsru ru rv �_add_default_conn_attrs� s � z'MySQLConnection._add_default_conn_attrsc C s@ t | j�� �}|d tkr"t|��d| _| j�|�}|d }| �t |t t tf�rT|nd�| _| j �| j� |d tj@ s�| js�| jdkr�td��| jdkr�td ��| j�d �r�tddd ��| jtj M _n| js�| jtjO _|d tj@ r�tjg| _|d tj@ �rd| _tjg| _|d tj@ �r6tjg| _|| _dS )z'Get the handshake from the MySQL server� NZserver_version_original�UnknownZcapabilitiesZmysql_clear_passwordzEClear password authentication is not supported over insecure channelsZ$authentication_openid_connect_clientzEOpenID Connect authentication is not supported over insecure channelsZverify_certz1SSL is required but the server doesn't support iti� )�errnoT)�bytesrV �recvr: r2 rW rU Zparse_handshakeZ_check_server_version� isinstancerz � bytearray�_server_versionZ_character_setZset_mysql_versionr �SSLZ is_secureri r+ ra �getr\ � _ssl_disabledZPLUGIN_AUTH�client_flags�CLIENT_QUERY_ATTRIBUTESrk ZMULTI_FACTOR_AUTHENTICATION)rr �packet� handshakeZserver_versionru ru rv � _do_handshake� sL �� � �� zMySQLConnection._do_handshakeNr z Optional[str]�intz:Optional[Dict[str, Optional[Union[str, bool, List[str]]]]]zOptional[Dict[str, str]]�bool)�username�password�databaser� �ssl_options� conn_attrsrS c C s | j �d�s"| j �d�r>tjdkr>|s>t�� }t�d|| j � | jrT|| jkrT| j}d| _ | j s�|tj@ r�| j j| j| j|| j|d� d| _ | j j| j| j| j| j| jd�d � | j j| j| j||| j| j|| j|| j | j|d �}| �|� |tj@ �s|�r| �|� dS )ae Authenticate with the MySQL server Authentication happens in two parts. We first send a response to the handshake. The MySQL server will then send either an AuthSwitchRequest or an error packet. Raises NotSupportedError when we get the old, insecure password reply back. Raises any error coming from MySQL. Zauthentication_ociZauthentication_kerberos�ntz4MySQL user is empty, OS user: %s will be used for %sF)�charsetr� T)Zkrb_service_principal�oci_config_file�oci_config_profileZwebauthn_callback�openid_token_file��config)�sockr� r� � password1� password2� password3r� r� r� �auth_plugin�auth_plugin_classr� ) ri � startswithr� �name�getpass�getuserr3 �debug� _password1rh r� r r� rn Z setup_sslrV �server_host�_charset_id�update_plugin_configrj �_oci_config_file�_oci_config_profileZ_webauthn_callback�_openid_token_file�authenticaterW � _password2� _password3�_auth_plugin_class� _handle_ok�CONNECT_WITH_DB�cmd_init_db)rr r� r� r� r� r� r� �ok_pktru ru rv �_do_auth sh � ������� � zMySQLConnection._do_authr4 c C sF d}| j r"tjdkr"t| jd�}nt| j| j| jd�}|� | j � |S )z�Get connection based on configuration This method will return the appropriated connection object using the connection parameters. Returns subclass of MySQLBaseSocket. N�posix)�unix_socket)�host�portZ force_ipv6)r` r� r� r6 r� r5 r� Zserver_portrb �set_connection_timeoutZ_connection_timeout)rr �connru ru rv �_get_connectionU s �zMySQLConnection._get_connectionc C sx | j }| j}d | _ | _| jdkr@| js@t| j| j�}|�� | _t� | _| � � | _ z�z`| j �� | �� | � | j| j| j| j| j| j� | j| _| jtj@ r�| j �� | j �d� W nT t�y } z:| j �� t|ttf�r�t|j|j d�|�|�W Y d}~n d}~0 0 W || _ || _n|| _ || _0 | j!�stt"| j j#d��rtt$| j j#j%��rt| j j#�%� \}}}t&|� t'||� dS )z�Open the connection to the MySQL server This method sets up and opens the connection to the MySQL server. Raises on errors. NZauthentication_kerberos_client)r� �msg�cipher)(�read_timeout� write_timeoutri r] r r� Zget_user_from_credentialsr= rU r� rV �open_connectionr� r� r^ r_ r\ ra r� rZ Zconverter_classr ZCOMPRESSZswitch_to_compressed_moder� rp �close_connectionr� r0 r1 r( r� r� r� �hasattrr� �callabler� rL rK )rr Zstored_read_timeoutZstored_write_timeout�cls�errr� Ztls_version�_ru ru rv �_open_connectionj s\ � ������z MySQLConnection._open_connectionc C s4 | j s dS z| j �� W n ttfy. Y n0 dS )ah Shut down connection to MySQL Server. This method closes the socket. It raises no exceptions. Unlike `disconnect()`, `shutdown()` closes the client connection without attempting to send a QUIT command to the server first. Thus, it will not block if the connection is disrupted for some reason such as network failure. N)rV �shutdown�AttributeErrorr* �rr ru ru rv r� � s zMySQLConnection.shutdownc C s� | j r$| j �� r$t| j t�� d � | js.d S z| �� W n ttfyP Y n0 zXz| j� � W n6 t y� } ztr�t| j |� � W Y d }~n d }~0 0 W tr�t| j � ntr�t| j � 0 d | _ d S )Nr )Z_spanZis_recordingrO �sys�exc_inforV �cmd_quitr� r* r� rp r7 rN rW )rr r� ru ru rv rq � s&