3
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                   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   s4   yt dj}|j| _dS  ttfk
r.   dS X d S )Nzpymysql.cursorsTF)
__import__cursorsZSSCursorZ	_sscursorImportErrorAttributeError)selfr	    r   G/tmp/pip-build-6_cqtusv/SQLAlchemy/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| j|||rdS t|| jjrBt|j }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_e)r   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