AlkantarClanX12

Your IP : 18.117.71.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/MySQLdb/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/MySQLdb/__pycache__/connections.cpython-37.pyc

B

��XG9�@s�dZddlZddlZddlmZddlmZmZddlm	Z	m
Z
mZmZm
Z
mZmZmZmZmZddlZes�ejdd�dkr�dd	�ed
�D�Zdd�Znd
d�Zdd�Ze�d�Zdd�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)�unicode�PY2)
�Warning�Error�InterfaceError�	DataError�
DatabaseError�OperationalError�IntegrityError�
InternalError�NotSupportedError�ProgrammingError�)��cCs(g|] }|dkrt|�n
t|d��qS)�i�)�chr)�.0�i�r�F/opt/alt/python37/lib64/python3.7/site-packages/MySQLdb/connections.py�
<listcomp>sr�cCs|�d��t�S)N�latin1)�decode�	translate�_surrogateescape_table)�srrr�_fast_surrogateescapesrcCs|�dd�S)N�ascii�surrogateescape)r)rrrrrscCsV||f}|r|j�|�n|j�|�~~t|t�r8|�|dk	rJ||��nt|��dS)a*
    If cursor is not None, (errorclass, errorvalue) is appended to
    cursor.messages; otherwise it is appended to
    connection.messages. Then errorclass is raised with errorvalue as
    the value.

    You can override this with your own error handler by assigning it
    to the instance.
    N)�messages�append�
isinstance�
BaseException�	Exception)�
connection�cursorZ
errorclassZ
errorvalue�errorrrr�defaulterrorhandler s


r*z^(\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
    �N)�re_numeric_part�match�int�group)r�mrrr�numeric_part;s

r1cs�eZdZdZejZdZ�fdd�Zdd�Z	ddd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zeejd�spdd�Z�fdd�Zdd�Zdd�ZeZeZeZeZeZeZeZeZeZe Z e!Z"�Z#S)�
Connectionz MySQL Database Connection ObjectNcs.ddlm}m}ddlm}ddlm}|��}d|krF|�d�|d<d|kr\|�d�|d<d	|krn|d	}n|}i}	xB|�	�D]6\}
}t
|
t�r�t
|t�r�|d
d
�|	|
<q�||	|
<q�W|	|d	<|�d|j
�}|�dd
�}
|
s�ts�d}nd}|�d|�}|�dd
�}|�dd�}|�dd�}tdd�t���d�d
d�D��}|dk�rV||jO}|dk�rj||jO}||d<|�dd�}|�dd
�|_tt|�j||�||_tdd�|�	�D��|_tdd�|���d�d
d�D��|_||���fdd�}�fd d!�}�fd"d#�}d$d%�}|�}|�|_}|�}|�|_ }|
�sH|�!�}
|�"|
�|�rb|�#|�|�r�|j$|j%�&d
|f�|j$|j'�&d
|f�|j$|j(�&d
|f�|j$|j)�&d
|f�|�r�t�r�|n||jt*<||jt+<n
||jt*<||jt,<|j-|j.@|_/|j/�r$|d
k	�r$|�0|�g|_1d
S)&a�
        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 str 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 strings.  columns are returned as
            normal strings. Unicode objects will always be encoded to
            the connection's character set regardless of this setting.
            Default to False on Python 2 and True on Python 3.

        :param str charset:
            If supplied, the connection character set will be changed
            to this character set (MySQL-4.1 and newer). This implies
            use_unicode=True.

        :param str sql_mode:
            If supplied, the session SQL mode will be changed to this
            setting (MySQL-4.1 and newer). 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 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)�proxyZdatabase�db�password�passwd�convN�cursorclass�charset�TF�use_unicode�sql_mode�
binary_prefix�client_flagcSsg|]}t|��qSr)r1)r�nrrrr�sz'Connection.__init__.<locals>.<listcomp>�.r)�r+)�r�
autocommit�waitercSs$g|]\}}t|�tk	r||f�qSr)�typer.)r�k�vrrrr�scSsg|]}t|��qSr)r1)rrBrrrr�scsd�fdd�	}|S)Ncs
��|�S)N)�string_literal)�obj�dummy)r7rrrK�szHConnection.__init__.<locals>._get_string_literal.<locals>.string_literal)Nr)rK)r7rr�_get_string_literal�sz0Connection.__init__.<locals>._get_string_literalcs*trd��fdd�	�nd��fdd�	��S)Ncs��|��j��S)N)rK�encoder<)�urM)r7�unicode_literalrrrQ�szJConnection.__init__.<locals>._get_unicode_literal.<locals>.unicode_literalcs��t|���j��S)N)rK�strrOr<)rPrM)r7rQrrrQ�s)N)N)rr)r7)rQr�_get_unicode_literal�sz1Connection.__init__.<locals>._get_unicode_literalcsd�fdd�	}|S)Ncsd��|�S)Ns_binary)rK)rLrM)r7rr�
bytes_literal�szFConnection.__init__.<locals>._get_bytes_literal.<locals>.bytes_literal)Nr)rT)r7rr�_get_bytes_literal�sz/Connection.__init__.<locals>._get_bytes_literalcs�fdd���S)Ncs|��j�S)N)rr<)r)�string_decoderrrrV�szHConnection.__init__.<locals>._get_string_decoder.<locals>.string_decoderrrr)rVr�_get_string_decoder�sz0Connection.__init__.<locals>._get_string_decoder)2ZMySQLdb.constantsr3r4ZMySQLdb.convertersr5�weakrefr6�copy�pop�itemsr$r.�list�default_cursorr�get�tuple�_mysqlZget_client_info�splitZMULTI_STATEMENTSZ
MULTI_RESULTSrG�superr2�__init__r;�dict�encodersZget_server_info�_server_versionrQrV�character_set_name�set_character_set�set_sql_mode�	converter�STRINGr#Z
VAR_STRINGZVARCHARZBLOB�bytes�	bytearrayrZserver_capabilitiesZTRANSACTIONSZ_transactionalrFr")�self�args�kwargsr3r4r5r6Zkwargs2r:Zconv2rIrJr;r<r>r?r@rAZclient_versionrFrNrSrUrWrKrQrTrV)�	__class__)r7rrcQs�J
$



&





zConnection.__init__cCs&t|�}|��|kr"tj�||�dS)N)�bool�get_autocommitr`r'rF)rn�onrrrrF
szConnection.autocommitcCs|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;)rnr;rrrr(szConnection.cursorcCsPt|t�rt|�}|jdk	r>|�|�|�|���|��ntj�	||�dS)N)
r$rmrlrGZ
send_query�filenoZread_query_resultr`r'�query)rnrvrrrrvs



zConnection.querycCs2ddlm}|dtd�|��r*|�d�|��S)Nr)�warnzRcontext interface will be changed.  Use explicit conn.commit() or conn.rollback().r�BEGIN)�warningsrw�DeprecationWarningrsrvr()rnrwrrr�	__enter__&s
zConnection.__enter__cCs|r|��n|��dS)N)ZrollbackZcommit)rn�exc�value�tbrrr�__exit__.s
zConnection.__exit__cCs,|�||j�}ts(t|ttf�r(t|�S|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.
        )�escapererr$rlrmr)rn�orrrr�literal4szConnection.literalcCs&ddlm}|dtd�|�d�dS)z�Explicitly begin a connection. Non-standard.
        DEPRECATED: Will be removed in 1.3.
        Use an SQL BEGIN statement instead.r)rwz2begin() is non-standard and will be removed in 1.4rrxN)ryrwrzrv)rnrwrrr�beginFszConnection.begin�
warning_countcCs$|��}|rt|��d�SdSdS)zpReturn the number of warnings generated from the
            last query. This is derived from the info() method.���rN)�infor.ra)rnr�rrrr�QszConnection.warning_countcs�|dkrd}n|}|��|krpytt|��|�Wn<tk
rn|jdkrTtd��|�d|�|��YnX||j	_
||j_
||_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.Zutf8mb4�utf8)rDr+z server is too old to set charsetzSET NAMES %sN)
rgrbr2rh�AttributeErrorrfr
rv�store_resultrVr<rQ�encoding)rnr<Z
py_charset)rqrrrhZs
zConnection.set_character_setcCs,|jdkrtd��|�d|�|��dS)zNSet the connection sql_mode. See MySQL documentation for
        legal values.)rDr+z!server is too old to set sql_modezSET SESSION sql_mode='%s'N)rfr
rvr�)rnr?rrrrios
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.)rDr+rz
SHOW WARNINGSr)rfrvr�Z	fetch_row)rn�rryrrr�
show_warningsws


zConnection.show_warnings)N)$�__name__�
__module__�__qualname__�__doc__rZCursorr]rGrcrFr(rvr{rr�r��hasattrr`r'r�rhrir�rrrr	rr
rrrr
r*Zerrorhandler�
__classcell__rr)rqrr2Ks8=
			r2)r��re�sysZMySQLdbrZMySQLdb.compatrrZ_mysql_exceptionsrrrrr	r
rrr
rr`�version_info�rangerrr*�compiler,r1r'r2rrrr�<module>s0