Your IP : 216.73.216.213


Current Path : /opt/alt/python38/lib64/python3.8/site-packages/MySQLdb/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/site-packages/MySQLdb/__pycache__/connections.cpython-38.pyc

U

�r�^^1�@s�dZddlZddlmZmZddlmZmZmZm	Z	m
Z
mZmZm
Z
mZmZddddd	d
�Ze�d�Zdd
�ZGdd�dej�ZdS)a
This module implements connections for MySQLdb. Presently there is
only one class: Connection. Others are unlikely. However, you might
want to make your own subclasses. In most cases, you will probably
override Connection.default_cursor with a non-standard Cursor class.
�N�)�cursors�_mysql)
�Warning�Error�InterfaceError�	DataError�
DatabaseError�OperationalError�IntegrityError�
InternalError�NotSupportedError�ProgrammingError�utf8�cp1252�koi8_r�koi8_u)Zutf8mb4Zutf8mb3�latin1Zkoi8rZkoi8uz^(\d+)cCs t�|�}|rt|�d��SdS)z�Returns the leading numeric part of a string.

    >>> numeric_part("20-alpha")
    20
    >>> numeric_part("foo")
    >>> numeric_part("16b")
    16
    rN)�re_numeric_part�match�int�group)�s�m�r�F/opt/alt/python38/lib64/python3.8/site-packages/MySQLdb/connections.py�numeric_part#s

rcs�eZdZdZejZ�fdd�Zdd�Zdd�Z	dd	�Z
d dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�Zeejd�s|dd�Z�fdd�Zdd�Zdd�ZeZeZeZeZeZeZeZeZe Z e!Z!�Z"S)!�
Connectionz MySQL Database Connection Objectcs�ddlm}m}ddlm}m}ddlm}|��}d|krJ|�	d�|d<d|kr`|�	d�|d<d	|krr|d	}	n|}	i}
|	�
�D]6\}}t|t�r�t|t
�r�|d
d
�|
|<q�||
|<q�|
|d	<|�	d|j�}
|�dd
�}|�	dd�}|�	dd
�}|�	dd�|_|�dd�}tdd�t���d�d
d�D��}|dk�rF||jO}|dk�rZ||jO}||d<|�	dd�}t�j||�|
|_dd�|	�
�D�|_t|jt<tdd�|���d�d
d�D��|_d|_||��d!�fdd �	}|�s�|��}|� |�|�r
|�!|�|�rN|j"|j#|j$|j%|j&|j'|j(fD]}||j)|<�q0t*|j)|j+<||jt*<|j,|j-@|_.|j.�r�|d
k	�r�|�/|�g|_0d
S)"aQ
        Create a connection to the database. It is strongly recommended
        that you only use keyword parameters. Consult the MySQL C API
        documentation for more information.

        :param str host:        host to connect
        :param str user:        user to connect as
        :param str password:    password to use
        :param str passwd:      alias of password, for backward compatibility
        :param str database:    database to use
        :param str db:          alias of database, for backward compatibility
        :param int port:        TCP/IP port to connect to
        :param str unix_socket: location of unix_socket to use
        :param dict conv:       conversion dictionary, see MySQLdb.converters
        :param int connect_timeout:
            number of seconds to wait before the connection attempt fails.

        :param bool compress:   if set, compression is enabled
        :param str named_pipe:  if set, a named pipe is used to connect (Windows only)
        :param str init_command:
            command which is run once the connection is created

        :param str read_default_file:
            file from which default client values are read

        :param str read_default_group:
            configuration group to use from the default file

        :param type cursorclass:
            class object, used to create cursors (keyword only)

        :param bool use_unicode:
            If True, text-like columns are returned as unicode objects
            using the connection's character set. Otherwise, text-like
            columns are returned as bytes. Unicode objects will always
            be encoded to the connection's character set regardless of
            this setting.
            Default to True.

        :param str charset:
            If supplied, the connection character set will be changed
            to this character set.

        :param str auth_plugin:
            If supplied, the connection default authentication plugin will be
            changed to this value. Example values:
            `mysql_native_password` or `caching_sha2_password`

        :param str sql_mode:
            If supplied, the session SQL mode will be changed to this
            setting.
            For more details and legal values, see the MySQL documentation.

        :param int client_flag:
            flags to use or 0 (see MySQL docs or constants/CLIENTS.py)

        :param str ssl_mode:
            specify the security settings for connection to the server;
            see the MySQL documentation for more details
            (mysql_option(), MYSQL_OPT_SSL_MODE).
            Only one of 'DISABLED', 'PREFERRED', 'REQUIRED',
            'VERIFY_CA', 'VERIFY_IDENTITY' can be specified.

        :param dict ssl:
            dictionary or mapping contains SSL connection parameters;
            see the MySQL documentation for more details
            (mysql_ssl_set()).  If this is set, and the client does not
            support SSL, NotSupportedError will be raised.

        :param bool local_infile:
            enables LOAD LOCAL INFILE; zero disables

        :param bool autocommit:
            If False (default), autocommit is disabled.
            If True, autocommit is enabled.
            If None, autocommit isn't set and server default is used.

        :param bool binary_prefix:
            If set, the '_binary' prefix will be used for raw byte query
            arguments (e.g. Binary). This is disabled by default.

        There are a number of undocumented, non-standard methods. See the
        documentation for the MySQL C API for some hints on what they do.
        r)�CLIENT�
FIELD_TYPE)�conversions�
_bytes_or_str)�proxyZdatabase�db�password�passwd�convN�cursorclass�charset��use_unicodeT�sql_modeZ
binary_prefixF�client_flagcSsg|]}t|��qSr�r��.0�nrrr�
<listcomp>�sz'Connection.__init__.<locals>.<listcomp>�.���r)�r�
autocommitcSs"i|]\}}t|�tk	r||�qSr)�typer)r/�k�vrrr�
<dictcomp>�sz'Connection.__init__.<locals>.<dictcomp>cSsg|]}t|��qSrr-r.rrrr1�s�asciics��|��j��S�N)�string_literal�encode�encoding)�u�dummy�r#rr�unicode_literal�sz,Connection.__init__.<locals>.unicode_literal)N)1ZMySQLdb.constantsrrZMySQLdb.convertersr r!�weakrefr"�copy�pop�items�
isinstancer�list�default_cursor�get�_binary_prefix�tuplerZget_client_info�splitZMULTI_STATEMENTSZ
MULTI_RESULTS�super�__init__r'�encoders�bytesZget_server_info�_server_versionr@�character_set_name�set_character_set�set_sql_mode�STRINGZ
VAR_STRINGZVARCHARZ	TINY_BLOBZMEDIUM_BLOBZ	LONG_BLOBZBLOB�	converter�strZJSONZserver_capabilitiesZTRANSACTIONSZ_transactionalr7�messages)�self�args�kwargsrrr r!r"Zkwargs2r&Zconv2r9r:r'r(r*r+r,Zclient_versionr7rD�t��	__class__rCrrQ8s�U

�




�

�	


zConnection.__init__cCs|Sr=r�r\rrr�	__enter__�szConnection.__enter__cCs|��dSr=)�close)r\�exc_type�	exc_value�	tracebackrrr�__exit__�szConnection.__exit__cCs&t|�}|��|kr"tj�||�dSr=)�boolZget_autocommitr�
connectionr7)r\�onrrrr7�szConnection.autocommitNcCs|p|j|�S)z�
        Create a cursor on which queries may be performed. The
        optional cursorclass parameter is used to create the
        Cursor. By default, self.cursorclass=cursors.Cursor is
        used.
        )r')r\r'rrr�cursor�szConnection.cursorcCs$t|t�rt|�}tj�||�dSr=)rI�	bytearrayrSrrj�query)r\rnrrrrn�s
zConnection.querycCs.t|ttf�st�|�|�}|jr*d|S|S)Ns_binary)rIrSrm�AssertionErrorr>rM)r\�bs�xrrr�_bytes_literals

zConnection._bytes_literalcCsdd�t|j|��S)Ns(%s)�,)�join�map�literal)r\r_rrr�_tuple_literalszConnection._tuple_literalcCs�t|t�r|�|�|j��}njt|t�r4|�|�}nTt|t�rJ|�|�}n>t|tt	f�rd|�
|�}n$|�||j�}t|t�r�|�|j�}t|t�s�t
�|S)aIf o is a single object, returns an SQL literal as a string.
        If o is a non-string sequence, the items of the sequence are
        converted and returned as a sequence.

        Non-standard. For internal use; do not use this in your
        applications.
        )rIrZr>r?r@rmrrrSrNrJrw�escaperRro)r\�orrrrrvs



zConnection.literalcCs|�d�dS)ziExplicitly begin a connection.

        This method is not used when autocommit=False (default).
        sBEGINN)rnrbrrr�begin&szConnection.begin�
warning_countcCs$|��}|rt|��d�SdSdS)zpReturn the number of warnings generated from the
            last query. This is derived from the info() method.���rN)�inforrO)r\r}rrrr{/szConnection.warning_countcspt�||�}|��|krfzt��|�Wn<tk
rd|jdkrJtd��|�d|�|�	�YnX||_
dS)z�Set the connection character set to charset. The character
        set can only be changed in MySQL-4.1 and newer. If you try
        to change the character set from the current value in an
        older version, NotSupportedError will be raised.r4z server is too old to set charsetzSET NAMES %sN)�_charset_to_encodingrLrUrPrV�AttributeErrorrTr
rn�store_resultr@)r\r(Z
py_charsetr`rrrV8s
zConnection.set_character_setcCs,|jdkrtd��|�d|�|��dS)zNSet the connection sql_mode. See MySQL documentation for
        legal values.r4z!server is too old to set sql_modezSET SESSION sql_mode='%s'N)rTr
rnr�)r\r+rrrrWHs
zConnection.set_sql_modecCs.|jdkrdS|�d�|��}|�d�}|S)z�Return detailed information about warnings as a
        sequence of tuples of (Level, Code, Message). This
        is only supported in MySQL-4.1 and up. If your server
        is an earlier version, an empty sequence is returned.r4rz
SHOW WARNINGSr)rTrnr�Z	fetch_row)r\�r�warningsrrr�
show_warningsPs


zConnection.show_warnings)N)#�__name__�
__module__�__qualname__�__doc__rZCursorrKrQrcrhr7rlrnrrrwrvrz�hasattrrrjr{rVrWr�rrrr	rr
rrrr
�
__classcell__rrr`rr3s84
		r)r��rer)rr�_exceptionsrrrrr	r
rrr
rr~�compilerrrjrrrrr�<module>s0�