o
    =a
                     @   s@   d Z ddlmZ ddlmZ ddlmZ G dd deZeZdS )	a  

.. dialect:: mysql+pymysql
    :name: PyMySQL
    :dbapi: pymysql
    :connectstring: mysql+pymysql://<username>:<password>@<host>/<dbname>[?<options>]
    :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 examples.


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.

   )MySQLDialect_mysqldb   )langhelpers)py3kc                       sl   e Zd ZdZdZdZdZdZej	dd Z
edd Zd fdd		Z fd
dZer2dd Z  ZS   ZS )MySQLDialect_pymysqlpymysqlTNc              	   C   s2   zt dj}|j| _W dS  ttfy   Y dS w )Nzpymysql.cursorsTF)
__import__cursorsSSCursor	_sscursorImportErrorAttributeError)selfr	    r   W/var/www/html/gps/gps/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/pymysql.pysupports_server_side_cursors9   s   
z1MySQLDialect_pymysql.supports_server_side_cursorsc                 C   s   t dS )Nr   )r   )clsr   r   r   dbapiB   s   zMySQLDialect_pymysql.dbapic                    s&   |d u r	t dd}tt| j||dS )Nuser)username)_translate_args)dictsuperr   create_connect_args)r   urlr   	__class__r   r   r   F   s
   

z(MySQLDialect_pymysql.create_connect_argsc                    sF   t t| |||rdS t|| jjr!t| }d|v p d|v S dS )NTzalready closedzconnection was killedF)r   r   is_disconnect
isinstancer   Errorstrlower)r   e
connectioncursorstr_er   r   r   r   M   s   
z"MySQLDialect_pymysql.is_disconnectc                 C   s$   t |jd tr|jd }|jd S )N    )r   args	Exception)r   	exceptionr   r   r   _extract_error_code\   s   

z(MySQLDialect_pymysql._extract_error_code)N)__name__
__module____qualname__driversupports_statement_cachedescription_encodingsupports_unicode_statementssupports_unicode_bindsr   memoized_propertyr   classmethodr   r   r   r   r*   __classcell__r   r   r   r   r   -   s    

r   N)__doc__mysqldbr   utilr   r   r   dialectr   r   r   r   <module>   s    5