L idZddlmZddlmZddlmZddlmZddlmZddlmZdd l m Z d d l m Z d d l mZer$d d lmZd dlmZd dlmZd dlmZd dlmZd dlmZGdde ZeZy)a .. dialect:: mysql+pymysql :name: PyMySQL :dbapi: pymysql :connectstring: mysql+pymysql://:@/[?] :url: https://pymysql.readthedocs.io/ Unicode ------- Please see :ref:`mysql_unicode` for current recommendations on unicode handling. .. _pymysql_ssl: SSL Connections ------------------ The PyMySQL DBAPI accepts the same SSL arguments as that of MySQLdb, described at :ref:`mysqldb_ssl`. See that section for additional examples. If the server uses an automatically-generated certificate that is self-signed or does not match the host name (as seen from the client), it may also be necessary to indicate ``ssl_check_hostname=false`` in PyMySQL:: connection_uri = ( "mysql+pymysql://scott:tiger@192.168.0.134/test" "?ssl_ca=/home/gord/client-ssl/ca.pem" "&ssl_cert=/home/gord/client-ssl/client-cert.pem" "&ssl_key=/home/gord/client-ssl/client-key.pem" "&ssl_check_hostname=false" ) MySQL-Python Compatibility -------------------------- The pymysql DBAPI is a pure Python port of the MySQL-python (MySQLdb) driver, and targets 100% compatibility. Most behavioral notes for MySQL-python apply to the pymysql driver as well. ) annotations)Any)Dict)Optional) TYPE_CHECKING)Union)MySQLDialect_mysqldb) langhelpers)Literal)ConnectArgsType)DBAPIConnection) DBAPICursor) DBAPIModule)PoolProxiedConnection)URLceZdZdZdZdZejd dZe d dZ ejd dZ d dZ d dfd Z dfd Zdd ZxZS)MySQLDialect_pymysqlpymysqlTNc| tdj}|j|_y#tt f$rYywxYw)Nzpymysql.cursorsTF) __import__cursorsSSCursor _sscursor ImportErrorAttributeError)selfrs g/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/dialects/mysql/pymysql.pysupports_server_side_cursorsz1MySQLDialect_pymysql.supports_server_side_cursorsNs?  !23;;G$--DN^,  s &);;ctdS)Nr)r)clss r import_dbapiz!MySQLDialect_pymysql.import_dbapiWs )$$c6 tdjj}tj|j } |j d}|dk(xr |j xs|jdduS#t$rYywxYw#ttf$rYywxYw)adetermine if pymysql has deprecated, changed the default of, or removed the 'reconnect' argument of connection.ping(). See #10492 and https://github.com/PyMySQL/mysqlclient/discussions/651#discussioncomment-7308971 for background. zpymysql.connectionsr reconnectrFT) r connections Connectionr get_callable_argspecpingargsdefaults IndexErrorrr)rr(insp reconnect_args r_send_false_to_pingz(MySQLDialect_pymysql._send_false_to_ping[s #%k**  33JOODD  $ ! % 3 %Fq)9)F   ^,  s#BA77 BBBBc`|jr|jdy|jy)NFT)r0r*)rdbapi_connections rdo_pingzMySQLDialect_pymysql.do_pingws/  # #  ! !% (  ! ! #r$cB| td}t| ||S)Nuser)username)_translate_args)dictsupercreate_connect_args)rurlr7 __class__s rr:z(MySQLDialect_pymysql.create_connect_argss1  ""F3Ow* +  r$ct||||ryt||jjr#t |j }d|vxsd|vSy)NTzalready closedzconnection was killedF)r9 is_disconnect isinstance loaded_dbapiErrorstrlower)re connectioncursorstr_er<s rr>z"MySQLDialect_pymysql.is_disconnects[ 7 J 7 4,,22 3FLLNE E)M-D-M r$cxt|jdtr|jd}|jdS)Nr)r?r+ Exception)r exceptions r_extract_error_codez(MySQLDialect_pymysql._extract_error_codes2 innQ' 3!q)I~~a  r$)returnbool)rLr)r2rrLz Literal[True])N)r;rr7zOptional[Dict[str, Any]]rLr)rDzDBAPIModule.ErrorrEz7Optional[Union[PoolProxiedConnection, DBAPIConnection]]rFzOptional[DBAPICursor]rLrM)rJ BaseExceptionrLr)__name__ __module__ __qualname__driversupports_statement_cachedescription_encodingr memoized_propertyr classmethodr#r0r3r:r>rK __classcell__)r<s@rrrHs F#""#%%""#6EI  )A   L&    !r$rN)__doc__ __future__rtypingrrrrrmysqldbr utilr util.typingr engine.interfacesrrrrr engine.urlrrdialectr$rrbsT)T# )"4400:!S!/S!l r$