
5dV
                 @   s   d  Z  d d l Z d d l m Z d d l m Z d d l Td d l j	 Z
 e Z d d   Z Gd d	   d	 e  Z Gd
 d   d e  Z d S)a)  psycopg 1.1.x compatibility module

This module uses the new style connection and cursor types to build a psycopg
1.1.1.x compatibility layer. It should be considered a temporary hack to run
old code while porting to psycopg 2. Import it as follows::

    from psycopg2 import psycopg1 as psycopg
    N)cursor)
connection)*c              O   s-   t  | d <t |  |   } | j t j  | S)zCconnect(dsn, ...) -> new psycopg 1.1.x compatible connection objectconnection_factory)r   	_2connectset_isolation_level_extISOLATION_LEVEL_READ_COMMITTED)argskwargsconn r   5/tmp/pip-build-0jahl3lb/psycopg2/psycopg2/psycopg1.pyconnect'   s    
r   c               @   s1   e  Z d  Z d Z d d   Z d d d  Z d S)r   zpsycopg 1.1.x connection.c             C   s   t  j |  d t S)z6cursor() -> new psycopg 1.1.x compatible cursor objectZcursor_factory)_2connectionr   )selfr   r   r   r   1   s    zconnection.cursor   c             C   s3   | d k r |  j  t j  n |  j  t j  d S)z;autocommit(on_off=1) -> switch autocommit on (1) or off (0)r   N)r   r   ZISOLATION_LEVEL_AUTOCOMMITr	   )r   Zon_offr   r   r   
autocommit5   s    zconnection.autocommitN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   .   s   r   c               @   sF   e  Z d  Z d Z d d   Z d d   Z d d   Z d d	   Z d
 S)r   zpsycopg 1.1.x cursor.

    Note that this cursor implements the exact procedure used by psycopg 1 to
    build dictionaries out of result rows. The DictCursor in the
    psycopg.extras modules implements a much better and faster algorithm.
    c             C   sC   i  } x6 t  t |  j   D] } | | | |  j | d <q W| S)Nr   )rangelendescription)r   rowresir   r   r   Z__build_dictE   s    zcursor.__build_dictc             C   s*   t  j |   } | r" |  j |  S| Sd  S)N)_2cursorZfetchone_cursor__build_dict)r   r   r   r   r   dictfetchoneK   s    zcursor.dictfetchonec             C   sC   g  } t  j |  |  } x$ | D] } | j |  j |   q W| S)N)r   Z	fetchmanyappendr   )r   sizer   rowsr   r   r   r   dictfetchmanyR   s
    zcursor.dictfetchmanyc             C   s@   g  } t  j |   } x$ | D] } | j |  j |   q W| S)N)r   Zfetchallr!   r   )r   r   r#   r   r   r   r   dictfetchallY   s
    zcursor.dictfetchallN)r   r   r   r   r   r    r$   r%   r   r   r   r   r   =   s
   r   )r   Z_psycopgZ	_2psycopgZpsycopg2.extensionsr   r   r   r   Zpsycopg2
extensionsr   r   r   r   r   r   r   <module>   s   
