U
    ÌZjÒ
  ã                   @   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                       sd   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r\dd„ Z‡  ZS )ÚMySQLDialect_pymysqlÚpymysqlTNc              	   C   s8   zt dƒj}|j| _W dS  ttfk
r2   Y dS X d S )Nzpymysql.cursorsTF)Ú
__import__ÚcursorsZSSCursorZ	_sscursorÚImportErrorÚAttributeError)Úselfr	   © r   úd/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/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 k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                    sJ   t t| ƒ |||¡rdS t|| jjƒrBt|ƒ ¡ }d|kp@d|kS dS d S )NTzalready closedzconnection was killedF)r   r   Úis_disconnectÚ
isinstancer   ÚErrorÚstrÚlower)r   ÚeÚ
connectionÚcursorZ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__ZdriverZsupports_statement_cacheZdescription_encodingZsupports_unicode_statementsZsupports_unicode_bindsr   Zmemoized_propertyr   Úclassmethodr   r   r   r   r'   Ú__classcell__r   r   r   r   r   -   s   

r   N)Ú__doc__Zmysqldbr   Úutilr   r   r   Údialectr   r   r   r   Ú<module>   s
    5