HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/clcommon/__pycache__/mysql_lib.cpython-37.pyc
B

wi�"��в�@s�ddlmZddlZddlmZyddlZWnFek
rryddlZWnek
r`dZYnXddlm	Z	YnXddl
m	Z	ddlmZddl
mZdZdZd	ZGd
d�d�Zdd
�Zeeefd�dddd�dd�ZdS)�)�annotationsN)�Iterable)�
DictCursor)�	load_fast)�	NoPackagez/etc/psa/psa.confz/etc/my.cnfz/etc/mysql/my.cnfc@s�eZdZd!dd�dd�Zdd�Zdd	�Zdd
�dd�Zd
d
�dd�Zd
d
�dd�Zdd�Z	e
dd��Zd"dddd�dd�Ze
ddd
d�dd ��ZdS)#�MySQLConnectorF�bool)�as_dictcKsBtdkrtd��|�|�dd�|�d|_|r2tnd|_||_dS)NzFCan not connect to database; MySQL-client libraries are not installed.�host�	localhost)�pymysqlr�add_unix_socket_if_localhost�get�_connectionr�_cursor_type�_connect_kwargs)�selfr	�kwargs�r��/builddir/build/BUILDROOT/alt-python27-cllib-3.4.1-1.el9.cloudlinux.x86_64/opt/alt/python37/lib/python3.7/site-packages/clcommon/mysql_lib.py�__init__%szMySQLConnector.__init__cCs|��S)N)�connect)rrrr�	__enter__1szMySQLConnector.__enter__cCs|��dS)N)�close)r�exc_type�	exc_value�	tracebackrrr�__exit__4szMySQLConnector.__exit__)�returncCstjf|j�|_|S)N)rrrr)rrrrr7szMySQLConnector.connect�NonecCs|jdk	r|j��dS)N)rr)rrrrr;s
zMySQLConnector.closecCs|jdk	r|j��dS)N)r�commit)rrrrr ?s
zMySQLConnector.commitcCs|j�|j�S)N)�
connection�cursorr)rrrrr"CszMySQLConnector.cursorcCs|jdkr|��|jS)N)rr)rrrrr!Fs
zMySQLConnector.connectionN�strzIterable[object] | Nonez&tuple[object, ...] | dict[str, object])�	sql_query�argsrc	Cs0|j�|j��}|j||d�|��SQRXdS)z:
        Execute SQL query and return the result.
        )r%N)r!r"rZexecuteZfetchall)rr$r%r"rrr�
execute_queryLszMySQLConnector.execute_query�dict)r
rrcCs|dkrd|krt�|d<dS)ag
        Add 'unix_socket' to kwargs if host is 'localhost'.

        It seems that when the host is set to 'localhost',
        establishing a connection through TCP/IP might encounter issues
        due to some MySQL configuration options.
        To prioritize a Unix socket connection,
        we should include the 'unix_socket' query parameter.
        rZunix_socketN)�get_unix_socket_path)r
rrrrr
Tsz+MySQLConnector.add_unix_socket_if_localhost)F)N)�__name__�
__module__�__qualname__rrrrrr r"�propertyr!r&�staticmethodr
rrrrr#srcCst�|j|j�|S)zF
    Get a modified RFC 1738 URL for a MySQL database connection.
    )rr
r
Zquery)Zurlrrr�get_rfc1738_db_uricsr.)�plesk_config_path�
mysql_configsr#z
Iterable[str])r/r0rcCsptj�|�r.t|dd�}|�d�}|dk	r.|Sx<|D]4}tj�|�sFq4t|dd�}|�d�}|dk	r4|Sq4WdS)	z�
    Get the Unix socket path for MySQL connection.

    Check Plesk and MySQL config files for the socket path.
    If found, return that path. If not, return default socket path.
    � )Z	delimiterZMYSQL_SOCKETNT)Zstrip_quotesZsocketz/var/lib/mysql/mysql.sock)�os�path�isfilerr)r/r0Zpsa_confZpsa_conf_socketZmy_conf_pathZmy_confZmy_conf_socketrrrr(ks


r()Z
__future__rr2�typingrr�ImportErrorZMySQLdbZMySQLdb.cursorsrZpymysql.cursorsZclcommon.clconfparsrZclcommon.cpapi.cpapiexceptionsrZPLESK_CONFIG_PATHZMY_CONFIG_PATHZMY_CONFIG_PATH2rr.r(rrrr�<module>s(
@