L iq'dZddlmZddlZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z d d l m Z d d l mZd dl mZd dl mZd dl mZd dlmZd dlmZddlmZe rBddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(Gd d!eZ)Gd"d#eZ*Gd$d%Z+Gd&d'e+eZ,Gd(d)e+e Z-Gd*d+eZ.Gd,d-eZ/Gd.d/ee/Z0e/Z1e0Z2y)0a, .. dialect:: mysql+mysqlconnector :name: MySQL Connector/Python :dbapi: myconnpy :connectstring: mysql+mysqlconnector://:@[:]/ :url: https://pypi.org/project/mysql-connector-python/ Driver Status ------------- MySQL Connector/Python is supported as of SQLAlchemy 2.0.39 to the degree which the driver is functional. There are still ongoing issues with features such as server side cursors which remain disabled until upstream issues are repaired. .. warning:: The MySQL Connector/Python driver published by Oracle is subject to frequent, major regressions of essential functionality such as being able to correctly persist simple binary strings which indicate it is not well tested. The SQLAlchemy project is not able to maintain this dialect fully as regressions in the driver prevent it from being included in continuous integration. .. versionchanged:: 2.0.39 The MySQL Connector/Python dialect has been updated to support the latest version of this DBAPI. Previously, MySQL Connector/Python was not fully supported. However, support remains limited due to ongoing regressions introduced in this driver. Connecting to MariaDB with MySQL Connector/Python -------------------------------------------------- MySQL Connector/Python may attempt to pass an incompatible collation to the database when connecting to MariaDB. Experimentation has shown that using ``?charset=utf8mb4&collation=utfmb4_general_ci`` or similar MariaDB-compatible charset/collation will allow connectivity. ) annotationsN)Any)cast)Optional)Sequence)Tuple) TYPE_CHECKING)Union)MariaDBIdentifierPreparer) MySQLCompiler) MySQLDialect)MySQLExecutionContext)MySQLIdentifierPreparer)MariaDBDialect)BIT)util) Connection) CursorResult)ConnectArgsType)DBAPIConnection) DBAPICursor) DBAPIModule)IsolationLevel)PoolProxiedConnection)Row)URL)BinaryExpressionceZdZddZddZy)$MySQLExecutionContext_mysqlconnectorc:|jjdS)NFbuffered_dbapi_connectioncursorselfs n/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/dialects/mysql/mysqlconnector.pycreate_server_side_cursorz>MySQLExecutionContext_mysqlconnector.create_server_side_cursorTs%%,,e,<<c:|jjdS)NTr#r%r(s r*create_default_cursorz:MySQLExecutionContext_mysqlconnector.create_default_cursorWs%%,,d,;;r,N)returnr)__name__ __module__ __qualname__r+r.r,r*r!r!Ss =r/r>)r0r1r2propertyrBsetterrKr3r,r*r@r@fs3   r,r@c eZdZy)&MySQLIdentifierPreparer_mysqlconnectorNr0r1r2r3r,r*rQrQw r,rQc eZdZy)(MariaDBIdentifierPreparer_mysqlconnectorNrRr3r,r*rUrU}rSr,rUceZdZddZy) _myconnpyBITcy)z0MySQL-connector already converts mysql bits, so.Nr3)r)dialectcoltypes r*result_processorz_myconnpyBIT.result_processorsr,N)rYrrZrr/rM)r0r1r2r[r3r,r*rWrWsr,rWcVeZdZUdZdZdZdZdZdZdZ dZ e Z e ZeZded<ej&ej*eeiZeddZddZdd Zej8dd Zdd Zdd Z dd Z d ddZ! d ddZ" ddZ#ddZ$ dfd Z%xZ&S) MySQLDialect_mysqlconnectormysqlconnectorTFformatztype[MySQLIdentifierPreparer]preparerc@tdtdjS)Nrzmysql.connector)r __import__ connector)clss r* import_dbapiz(MySQLDialect_mysqlconnector.import_dbapisM:.?#@#J#JKKr,c&|jdy)NFT)ping)r)dbapi_connections r*do_pingz#MySQLDialect_mysqlconnector.do_pingse$r,c|jd}|j|jtj|dt tj|dt tj|dt tj|dt tj|dt tj|dt tj|d t tj|d t tj|d t tj|d t tj|d t tj|dt tj|dt tj|dt tj|dt tj|dt tj|dt d|d<|jK ddlm }|j}|jd|j}||jz}||d<g|fSg|fS#t$rYg|fSwxYw)Nuser)usernameallow_local_infile autocommitr$ client_flagcompressconnection_timeoutconnect_timeoutconsume_results force_ipv6 get_warningspool_reset_session pool_sizeraise_on_warningsrawssl_verify_certuse_pure use_unicodeTr) constants client_flags)translate_connect_argsupdatequeryrcoerce_kw_typerLintdbapimysql.connectorr} ClientFlagget get_default FOUND_ROWS Exception)r)urloptsr}rr~s r*create_connect_argsz/MySQLDialect_mysqlconnector.create_connect_argss))6): CII D"6= D,5 D*d3 D-5 D*d3 D"6< D"3S9 D"3T: D,5 D.$7 D"6= D+s3 D"5t< D%. D"3T: D*d3 D-6 Z :: ! 5&11 #xx"J$:$:$<   5 55 '3^$4xr4x 4x s AI I('I(c|jret|jdrOtjd|jj}|r#t d|j dddDSy)N __version__z(\d+)\.(\d+)(?:\.(\d+))?c38K|]}|t|ywrD)r).0xs r* zKMySQLDialect_mysqlconnector._mysqlconnector_version_info..sOSVOsr r)rhasattrrematchrtuplegroup)r)ms r*_mysqlconnector_version_infoz8MySQLDialect_mysqlconnector._mysqlconnector_version_infosU ::'$**m<4djj6L6LMAOQWWQ1-=OOOr,c.|jjSrD) connectioncharset)r)rs r*_detect_charsetz+MySQLDialect_mysqlconnector._detect_charsets$$,,,r,c|jSrD)errno)r) exceptions r*_extract_error_codez/MySQLDialect_mysqlconnector._extract_error_codes r,cd}|jj|jj|jjf}t ||r,|j |vxsdt |vxs dt |vSy)N)iiiiiizMySQL Connection not available.z$Connection to MySQL is not availableF) loaded_dbapiOperationalErrorInterfaceErrorProgrammingError isinstancerr>)r)err'errnos exceptionss r* is_disconnectz)MySQLDialect_mysqlconnector.is_disconnects 6    . .    , ,    . . a $6!D4A>D9SVC  r,c"|jSrD)fetchallr)rprs r*_compat_fetchallz,MySQLDialect_mysqlconnector._compat_fetchall {{}r,c"|jSrD)fetchoners r*_compat_fetchonez,MySQLDialect_mysqlconnector._compat_fetchonerr,cy)N) SERIALIZABLEzREAD UNCOMMITTEDzREAD COMMITTEDzREPEATABLE READ AUTOCOMMITr3r) dbapi_conns r*get_isolation_level_valuesz6MySQLDialect_mysqlconnector.get_isolation_level_values s r,c,t|jSrD)rLrnrs r*detect_autocommit_settingz5MySQLDialect_mysqlconnector.detect_autocommit_settingsJ))**r,cN|dk(rd|_yd|_t| ||y)NrTF)rnsuperset_isolation_level)r)rhlevel __class__s r*rz/MySQLDialect_mysqlconnector.set_isolation_levels/ L *.  '*/  ' G '(8% @r,)r/r)rhrr/rL)rrr/r)r/zOptional[Tuple[int, ...]])rrr/r>)r BaseExceptionr/r)rrrz7Optional[Union[PoolProxiedConnection, DBAPIConnection]]r'zOptional[DBAPICursor]r/rLrD)rCursorResult[Tuple[Any, ...]]r Optional[str]r/zSequence[Row[Tuple[Any, ...]]])rrrrr/zOptional[Row[Tuple[Any, ...]]])rrr/zSequence[IsolationLevel])rrr/rL)rhrrrr/rM)'r0r1r2driversupports_statement_cachesupports_sane_rowcountsupports_sane_multi_rowcountsupports_native_decimalsupports_native_bitsupports_server_side_cursorsdefault_paramstyler5statement_compilerr!execution_ctx_clsrQr`__annotations__r update_copyrcolspecsrrW classmethodrerirmemoized_propertyrrrrrrrrr __classcell__)rs@r*r]r]so F#!#' "$) !5< / + t 5 5\7JKHLL/b - L&   0"& ) ( "& ) (   )  !  +A /A8FA AAr,r]ceZdZdZdZeZy)MariaDBDialect_mysqlconnectorTFN)r0r1r2r_allows_uuid_bindsrUr`r3r,r*rr%s $7Hr,r)3__doc__ __future__rrtypingrrrrrr r baser r rrrmariadbrtypesrr engine.baser engine.cursorrengine.interfacesrrrrrr engine.rowr engine.urlr sql.elementsrr!r5r@rQrUrWr]rrYmariadb_dialectr3r,r*rs&N#  +')#)-44003:!!0<+@< = " +-D  +-F 3XA,XAv8/8 &/r,