3
am                 @   sz   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ G dd	 d	ej	Z
G d
d deZG dd deZeZdS )a  
.. dialect:: postgresql+pypostgresql
    :name: py-postgresql
    :dbapi: pypostgresql
    :connectstring: postgresql+pypostgresql://user:password@host:port/dbname[?key=value&key=value...]
    :url: https://python.projects.pgfoundry.org/

.. note::

    The pypostgresql dialect is **not tested as part of SQLAlchemy's continuous
    integration** and may have unresolved issues.  The recommended PostgreSQL
    driver is psycopg2.

.. deprecated:: 1.4 The py-postgresql DBAPI is deprecated and will be removed
   in a future version. This DBAPI is superseded by the external
    version available at external-dialect_. Please use the external version or
    one of the supported DBAPIs to connect to PostgreSQL.

.. TODO update link
.. _external-dialect: https://github.com/PyGreSQL

   )	PGDialect)PGExecutionContext   )
processors)types)utilc               @   s   e Zd Zdd Zdd ZdS )	PGNumericc             C   s   t jS )N)r   Zto_str)selfdialect r   Q/tmp/pip-build-6_cqtusv/SQLAlchemy/sqlalchemy/dialects/postgresql/pypostgresql.pybind_processor&   s    zPGNumeric.bind_processorc             C   s   | j r
d S tjS d S )N)Z	asdecimalr   Zto_float)r	   r
   Zcoltyper   r   r   result_processor)   s    zPGNumeric.result_processorN)__name__
__module____qualname__r   r   r   r   r   r   r   %   s   r   c               @   s   e Zd ZdS )PGExecutionContext_pypostgresqlN)r   r   r   r   r   r   r   r   0   s   r   c            	   @   s   e Zd ZdZdZdZdZdZdZdZ	dZ
eZejejejeejejiZedd Zdd	d
ddddddg	Zejdd Zdd Zdd ZdS )PGDialect_pypostgresqlZpypostgresqlTNZpyformatFc             C   s   ddl m} tjddd |S )N    )dbapi20zThe py-postgresql DBAPI is deprecated and will be removed in a future version. This DBAPI is superseded by the externalversion available at https://github.com/PyGreSQL. Please use one of the supported DBAPIs to connect to PostgreSQL.z1.4)version)Zpostgresql.driverr   r   Zwarn_deprecated)clsr   r   r   r   dbapiL   s
    zPGDialect_pypostgresql.dbapiErrorZInterfaceErrorZDatabaseErrorZ	DataErrorZOperationalErrorZIntegrityErrorZInternalErrorZProgrammingErrorZNotSupportedErrorc                s&    j d kri S t fdd jD S )Nc             3   s    | ]}t  j|j|fV  qd S )N)getattrr   r   ).0name)r	   r   r   	<genexpr>m   s   zIPGDialect_pypostgresql.dbapi_exception_translation_map.<locals>.<genexpr>)r   dict_DBAPI_ERROR_NAMES)r	   r   )r	   r   dbapi_exception_translation_mapg   s
    

z6PGDialect_pypostgresql.dbapi_exception_translation_mapc             C   sB   |j dd}d|kr&t|d |d< nd|d< |j|j g |fS )Nuser)usernameporti8  )Ztranslate_connect_argsintupdatequery)r	   urloptsr   r   r   create_connect_argsq   s    z*PGDialect_pypostgresql.create_connect_argsc             C   s   dt |kS )Nzconnection is closed)str)r	   e
connectioncursorr   r   r   is_disconnectz   s    z$PGDialect_pypostgresql.is_disconnect)r   r   r   ZdriverZsupports_statement_cacheZsupports_unicode_statementsZsupports_unicode_bindsZdescription_encodingZdefault_paramstyleZsupports_sane_rowcountZsupports_sane_multi_rowcountr   Zexecution_ctx_clsr   Zupdate_copyr   ZcolspecssqltypesNumericr   ZFloatclassmethodr   r   Zmemoized_propertyr    r)   r.   r   r   r   r   r   4   s4   
	r   N)__doc__baser   r    r   r   r/   r   r0   r   r   r   r
   r   r   r   r   <module>   s   J