g[3dZddlZddlmZmZddlmZmZmZm Z m Z m Z m Z m Z mZmZddddd d Zej"d Zd ZGd dej(Zy)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) WarningErrorInterfaceError DataError DatabaseErrorOperationalErrorIntegrityError InternalErrorNotSupportedErrorProgrammingErrorutf8cp1252koi8_rkoi8_u)utf8mb4utf8mb3latin1koi8rkoi8uz^(\d+)cftj|}|rt|jdSy)zReturns the leading numeric part of a string. >>> numeric_part("20-alpha") 20 >>> numeric_part("foo") >>> numeric_part("16b") 16 rN)re_numeric_partmatchintgroup)sms D/opt/hc_python/lib64/python3.12/site-packages/MySQLdb/connections.py numeric_partr!#s, a A1771: ceZdZdZej ZfdZ ddZdZ dZ dZ ddZ dZ d Zd Zd Zd Zdfd ZdZdZeZeZeZeZeZeZeZeZeZeZxZS) Connectionz MySQL Database Connection Objectctddlm}m}ddlm}m}|j }d|vr|jd|d<d|vr|jd|d<d|vr|d}n|}i} |jD]3\} } t| trt| tr | d d | | </| | | <5| |d<|jd |j} |jd d } |jd d }|jdd}|jdd }|jdd|_|jdd}||jz}|jdd}|r||j z}||d<|jdd}|j"|i|t%|L|i|| |_|jD cic]\} } t+| tur| | c} } |_t/|j1j3dd dDcgc] }t5|c}|_d|_| s|j;} |j=| ||r|j?||r|j@|jB|jD|jF|jH|jJ|jLfD]}||jN|<tP|jN|jR<|jT|jVz|_,|jXr||j[|g|_.y cc} } wcc}w)aZ 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 (deprecated) :param str database: database to use :param str db: alias of database (deprecated) :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 collation: If ``charset`` and ``collation`` are both supplied, the character set and collation for the current connection will be set. If omitted, empty string, or None, the default collation for the ``charset`` is implied. :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 bool multi_statements: If True, enable multi statements for clients >= 4.1. Defaults to True. :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. Since mysqlclient 2.2.4, ssl=True is alias of ssl_mode=REQUIRED for better compatibility with PyMySQL and MariaDB. :param str server_public_key_path: specify the path to a file RSA public key file for caching_sha2_password. See https://dev.mysql.com/doc/refman/9.0/en/caching-sha2-pluggable-authentication.html :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_strdbdatabasepasswdpasswordconvN cursorclasscharset collation use_unicodeTsql_mode binary_prefixF client_flagmulti_statements autocommit.ascii)/MySQLdb.constantsr&r'MySQLdb.convertersr(r)copypopitems isinstancerlistdefault_cursorget_binary_prefix MULTI_RESULTSMULTI_STATEMENTS_set_attributessuper__init__r/typeencoderstupleget_server_infosplitr!_server_versionencodingcharacter_set_nameset_character_set set_sql_modeSTRING VAR_STRINGVARCHAR TINY_BLOB MEDIUM_BLOB LONG_BLOBBLOB converterstrJSONserver_capabilities TRANSACTIONS_transactionalr8messages)selfargskwargsr&r'r(r)kwargs2r.conv2kvr/r0r2r3r4r6r7r8nt __class__s r rJzConnection.__init__8sN 9A++- 7?")++d"3GJ  w ")++h"7GJ  V &>DDJJLDAq!S!jD&9Q4aa !  kk-1D1DE ++i,KK R0 kk-6 ;;z2.%kk/5Ajj2 v+++ ";;'94@  622 2K!, [[u5 d.g. $*'*&  $1Awc! qD$  %&*&:&:&<&B&B3&G&K L&K\!_&K L   --/G w 2    h ' !!%%""$$&&$$%2q!/2DNN:?? +"669L9LL   % + I Ms <L/ L5c H|r|sd}||_||_||_||_y)zset some attributes for otel localhostN)hostuserr+r*)rcrorpr-r+port unix_socketres r rHzConnection._set_attributess* tD    r"c|SNrcs r __enter__zConnection.__enter__s r"c$|jyrt)close)rcexc_type exc_value tracebacks r __exit__zConnection.__exit__s  r"ct|}|j|k7r!tjj ||yyrt)boolget_autocommitr connectionr8)rcons r r8zConnection.autocommits7 "X    B &    ( (r 2 'r"c.|xs |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/)rcr/s r cursorzConnection.cursor s0 /t//66r"czt|tr t|}tjj ||yrt)rA bytearraybytesrrquery)rcrs r rzConnection.querys+ eY '%LEe,r"czt|ttfsJ|j|}|jrd|zS|S)Ns_binary)rArrstring_literalrE)rcbsxs r _bytes_literalzConnection._bytes_literals?"ui0111    #   > !r"cRddjt|j|zS)Ns(%s),)joinmapliteral)rcrks r _tuple_literalzConnection._tuple_literal!s!$))C a$89::r"ct|tr+|j|j|j}nt|t r|j |}nt|tr|j |}not|ttfr|j|}nG|j||j}t|tr|j|j}t|tsJ|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. ) rAr]rencoderQrrrrMrBrescaperL)rcors r rzConnection.literal$s a ##AHHT]]$;r")NNNr1i Nrt) __name__ __module__ __qualname____doc__rCursorrCrJrHrwr}r8rrrrrrrSrTrrrrr r r r r rr __classcell__)rls@r r$r$3s*^^NwrVZ$( 3 7- ;.  G E#N!MI'#N!M')r"r$)rrer1rr _exceptionsrrrr r r r r rrrcompilerr!rr$rur"r rse        "**Y'  t*""t*r"