
H`Tc           @   s  d  Z  d d l m Z m Z d d l m Z m Z d d l Z d d l Z y d d l	 m
 Z
 d   Z Wn e k
 r d   Z n Xy d d	 l	 m Z Wn' e k
 r d
 e f d     YZ n Xd e f d     YZ y! d d l m Z e j e  Wn e k
 rn Xd e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d S(   sS   Define result set constructs including :class:`.ResultProxy`
and :class:`.RowProxy.i   (   t   exct   util(   t
   expressiont   sqltypesiN(   t   safe_rowproxy_reconstructorc         C   s   t  |  |  S(   N(   R   (   t   clst   state(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   rowproxy_reconstructor   s    c         C   s    |  j  |   } | j |  | S(   N(   t   __new__t   __setstate__(   R   R   t   obj(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR      s    (   t   BaseRowProxyR   c           B   sM   e  Z d Z d   Z d   Z d   Z d   Z d   Z d	   Z d
   Z	 RS(   t   _parentt   _rowt   _processorst   _keymapc         C   s(   | |  _  | |  _ | |  _ | |  _ d S(   s8   RowProxy objects are constructed by ResultProxy objects.N(   R   R   R   R   (   t   selft   parentt   rowt
   processorst   keymap(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __init__*   s    			c         C   s   t  |  j |  j   f f S(   N(   R   t	   __class__t   __getstate__(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt
   __reduce__2   s    c         C   s
   t  |   S(   s9   Return the values represented by this RowProxy as a list.(   t   list(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   values6   s    c         c   sI   xB t  |  j |  j  D]+ \ } } | d  k r6 | Vq | |  Vq Wd  S(   N(   t   zipR   R   t   None(   R   t	   processort   value(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __iter__:   s    "c         C   s   t  |  j  S(   N(   t   lenR   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __len__A   s    c         C   s&  y |  j  | \ } } } Wn t k
 rH |  j j |  \ } } } n t k
 r t | t  r g  } xZ t |  j | |  j	 |  D]; \ } } | d  k r | j |  q | j | |   q Wt |  S  n X| d  k r t j d |   n  | d  k	 r| |  j	 |  S|  j	 | Sd  S(   NsV   Ambiguous column name '%s' in result set! try 'use_labels' option on select statement.(   R   t   KeyErrorR   t   _key_fallbackt	   TypeErrort
   isinstancet   sliceR   R   R   R   t   appendt   tupleR    t   InvalidRequestError(   R   t   keyR   R
   t   indext   lR   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __getitem__D   s*    
c         C   s9   y |  | SWn& t  k
 r4 } t | j d   n Xd  S(   Ni    (   R"   t   AttributeErrort   args(   R   t   namet   e(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __getattr__^   s    (   s   _parents   _rows   _processorss   _keymap(
   t   __name__t
   __module__t	   __slots__R   R   R   R   R!   R-   R2   (    (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR   '   s   						t   RowProxyc           B   s   e  Z d  Z d Z d   Z d   Z d   Z d Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   sx  Proxy values from a single cursor row.

    Mostly follows "ordered dictionary" behavior, mapping result
    values to the string-based column name, the integer position of
    the result in the row, as well as Column instances which can be
    mapped to the original Columns that produced this result set (for
    results that correspond to constructed SQL expressions).
    c         C   s   |  j  j |  j |  S(   N(   R   t   _has_keyR   (   R   R*   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __contains__p   s    c         C   s   i |  j  d 6t |   d 6S(   NR   R   (   R   R(   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR   s   s    
c         C   s:   | d |  _  } | d |  _ | j |  _ | j |  _ d  S(   NR   R   (   R   R   R   R   (   R   R   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR	   y   s    c         C   s;   t  | t  r( | t |   t |   S| t |   |  S(   N(   R%   R6   R(   (   R   t   othert   op(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   _op   s    (c         C   s   |  j  | t j  S(   N(   R;   t   operatort   lt(   R   R9   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __lt__   s    c         C   s   |  j  | t j  S(   N(   R;   R<   t   le(   R   R9   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __le__   s    c         C   s   |  j  | t j  S(   N(   R;   R<   t   ge(   R   R9   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __ge__   s    c         C   s   |  j  | t j  S(   N(   R;   R<   t   gt(   R   R9   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __gt__   s    c         C   s   |  j  | t j  S(   N(   R;   R<   t   eq(   R   R9   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __eq__   s    c         C   s   |  j  | t j  S(   N(   R;   R<   t   ne(   R   R9   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __ne__   s    c         C   s   t  t |    S(   N(   t   reprR(   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __repr__   s    c         C   s   |  j  j |  j |  S(   s4   Return True if this RowProxy contains the given key.(   R   R7   R   (   R   R*   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   has_key   s    c         C   s'   g  |  j    D] } | |  | f ^ q S(   s@   Return a list of tuples, each tuple containing a key/value pair.(   t   keys(   R   R*   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   items   s    c         C   s
   |  j  j S(   s@   Return the list of keys as strings represented by this RowProxy.(   R   RL   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyRL      s    c         C   s   t  |  j j  S(   N(   t   iterR   RL   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   iterkeys   s    c         C   s
   t  |   S(   N(   RN   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt
   itervalues   s    (    N(   R3   R4   t   __doc__R5   R8   R   R	   R   t   __hash__R;   R>   R@   RB   RD   RF   RH   RJ   RK   RM   RL   RO   RP   (    (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR6   e   s&   															(   t   Sequencet   ResultMetaDatac           B   sY   e  Z d  Z d   Z e j d d  d    Z e d  Z d   Z	 d   Z
 d   Z RS(	   sR   Handle cursor.description, applying additional info from an execution
    context.c         C   s  g  |  _  } i  |  _ } g  |  _ | j } | j } | j } | j } | j |  _ i  }	 xt |  D]\ }
 } | d } | d } | j	 r | j
 |  } n  | r | |  \ } } n  | j r | j |  } n  | j rIy/ | j |  j r | n	 | j   \ } } } Wqlt k
 rE| d  | j | t j  } } } qlXn# | d  | j | t j  } } } | j | | |  } | j |  | | |
 f } | |	 |
 <|	 j |  j r| n	 | j   |  | k	 rd  | d  f |	 |  j r| n	 | j   <} n  |  j j |  | r7x | D] } | | | <q Wn  | rf | rf | | | <qf qf W| j |	  | j r| j j j d t d   | D   n  d  S(   Ni    i   s   Col %rc         s   s   |  ] } | d  Vq d S(   i    N(    (   t   .0t   x(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pys	   <genexpr>  s    (   R   R   RL   t   contextt   dialectt   dbapi_type_mapt   _translate_colnamet   case_sensitivet	   enumeratet   description_encodingt   _description_decodert   requires_name_normalizet   normalize_namet
   result_mapt   lowerR"   R   t   getR   t   NULLTYPEt   get_result_processorR'   t
   setdefaultt   updatet   _echot   enginet   loggert   debugR(   (   R   R   t   metadataR   R   RW   RX   t   typemapt   translate_colnamet   primary_keymapt   it   rect   colnamet   coltypet   untranslatedR0   R
   t   type_R   t   o(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR      sZ    					

			)*#
		/	s   0.8s,   sqlite dialect uses _translate_colname() nowc         C   sg   |  j  |  j r | n	 | j   } \ } } } |  j  j | |  | k	 rc | | d f |  j  | <n  d S(   s   Set a synonym for the given name.

        Some dialects (SQLite at the moment) may use this to
        adjust the column names that are significant within a
        row.

        N(   R   R[   Rb   Rf   R   (   R   R0   t   orignameRq   R   R
   Rp   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   _set_keymap_synonym  s
    
c         C   s  |  j  } d  } t | t j  rH | j |  j r6 | n	 | j    } nt | t j	  r`| j
 r |  j ru | j
 n | j
 j   | k r | |  j r | j
 n | j
 j   } n^ t | d  r|  j r | j n | j j   | k r| |  j r | j n | j j   } n  | d  k	 r`| d d  k	 r`x. | d D] } | j |  r7Pq7q7Wd  } q`n  | d  k r| rt j d t j |    qd  Sn
 | | | <| S(   NR0   i   s.   Could not locate column in row for column '%s'(   R   R   R%   R   t   string_typesRc   R[   Rb   R   t   ColumnElementt   _labelt   hasattrR0   t   _compare_name_for_resultR    t   NoSuchColumnErrort   _string_or_unprintable(   R   R*   t   raiseerrt   mapt   resultR
   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR#   #  s>    	'	
c         C   s-   | |  j  k r t S|  j | t  d  k	 Sd  S(   N(   R   t   TrueR#   t   FalseR   (   R   R   R*   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR7   R  s    c         C   s8   i t  d   |  j j   D  d 6|  j d 6|  j d 6S(   Nc         s   sC   |  ]9 \ } \ } } } t  | t j t j  r | | f Vq d  S(   N(   R%   R   Ry   t	   int_types(   RU   R*   R   R
   R+   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pys	   <genexpr>[  s   t   _pickled_keymapRL   R[   (   t   dictR   RM   RL   R[   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR   X  s    
c         C   s   g  t  t | d   D] } d  ^ q |  _ i  |  _ } x1 | d j   D] \ } } d  d  | f | | <qJ W| d |  _ | d |  _ t |  _	 d  S(   NRL   R   R[   (
   t   rangeR    R   R   R   RM   RL   R[   R   Rh   (   R   R   t   _R   R*   R+   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR	   c  s    ,(   R3   R4   RQ   R   R   t   pending_deprecationRx   R   R#   R7   R   R	   (    (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyRT      s   	V/		t   ResultProxyc           B   s^  e  Z d  Z e Z d Z e Z d Z	 d   Z
 d   Z d   Z e j d    Z e d    Z e d    Z e d    Z d   Z e d	  Z d
   Z e j d    Z d   Z d   Z e d    Z d   Z d   Z d   Z d   Z d   Z  d   Z! d d  Z" d   Z# d   Z$ d   Z% d   Z& d d  Z' d   Z( d   Z) d   Z* RS(   s[  Wraps a DB-API cursor object to provide easier access to row columns.

    Individual columns may be accessed by their integer position,
    case-insensitive column name, or by ``schema.Column``
    object. e.g.::

      row = fetchone()

      col1 = row[0]    # access via integer position

      col2 = row['col2']   # access via name

      col3 = row[mytable.c.mycol] # access via Column object.

    ``ResultProxy`` also handles post-processing of result column
    data using ``TypeEngine`` objects, which are referenced from
    the originating SQL statement that produced this result set.

    c         C   si   | |  _  | j |  _ t |  _ | j |  _ |  _ | j |  _ |  j j oU | j	 j
   |  _ |  j   d  S(   N(   RW   RX   R   t   closedt   cursort   _saved_cursort   root_connectiont
   connectionRh   Ri   t   _should_log_debugt   _init_metadata(   R   RW   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    		c         C   s1   |  j    } | d  k	 r- t |  |  |  _ n  d  S(   N(   t   _cursor_descriptionR   RT   t	   _metadata(   R   Rl   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c         C   s   |  j  r |  j  j Sg  Sd S(   s/   Return the current set of string keys for rows.N(   R   RL   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyRL     s    	
c         C   sJ   y |  j  j SWn5 t k
 rE } |  j j | d d |  j |  j   n Xd S(   s  Return the 'rowcount' for this result.

        The 'rowcount' reports the number of rows *matched*
        by the WHERE criterion of an UPDATE or DELETE statement.

        .. note::

           Notes regarding :attr:`.ResultProxy.rowcount`:


           * This attribute returns the number of rows *matched*,
             which is not necessarily the same as the number of rows
             that were actually *modified* - an UPDATE statement, for example,
             may have no net change on a given row if the SET values
             given are the same as those present in the row already.
             Such a row would be matched but not modified.
             On backends that feature both styles, such as MySQL,
             rowcount is configured by default to return the match
             count in all cases.

           * :attr:`.ResultProxy.rowcount` is *only* useful in conjunction
             with an UPDATE or DELETE statement.  Contrary to what the Python
             DBAPI says, it does *not* return the
             number of rows available from the results of a SELECT statement
             as DBAPIs cannot support this functionality when rows are
             unbuffered.

           * :attr:`.ResultProxy.rowcount` may not be fully implemented by
             all dialects.  In particular, most DBAPIs do not support an
             aggregate rowcount result from an executemany call.
             The :meth:`.ResultProxy.supports_sane_rowcount` and
             :meth:`.ResultProxy.supports_sane_multi_rowcount` methods
             will report from the dialect if each usage is known to be
             supported.

           * Statements that use RETURNING may not return a correct
             rowcount.

        N(   RW   t   rowcountt	   ExceptionR   t   _handle_dbapi_exceptionR   R   (   R   R1   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s
    )	c         C   sJ   y |  j  j SWn5 t k
 rE } |  j j | d d |  j  |  j  n Xd S(   s/  return the 'lastrowid' accessor on the DBAPI cursor.

        This is a DBAPI specific method and is only functional
        for those backends which support it, for statements
        where it is appropriate.  It's behavior is not
        consistent across backends.

        Usage of this method is normally unnecessary when
        using insert() expression constructs; the
        :attr:`~ResultProxy.inserted_primary_key` attribute provides a
        tuple of primary key values for a newly inserted row,
        regardless of database backend.

        N(   R   t	   lastrowidR   R   R   R   RW   (   R   R1   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    		c         C   s   |  j  d k	 S(   s   True if this :class:`.ResultProxy` returns rows.

        I.e. if it is legal to call the methods
        :meth:`~.ResultProxy.fetchone`,
        :meth:`~.ResultProxy.fetchmany`
        :meth:`~.ResultProxy.fetchall`.

        N(   R   R   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   returns_rows  s    
c         C   s
   |  j  j S(   sd  True if this :class:`.ResultProxy` is the result
        of a executing an expression language compiled
        :func:`.expression.insert` construct.

        When True, this implies that the
        :attr:`inserted_primary_key` attribute is accessible,
        assuming the statement did not include
        a user defined "returning" construct.

        (   RW   t   isinsert(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt	   is_insert  s    c         C   s
   |  j  j S(   s    May be overridden by subclasses.(   R   t   description(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c         C   sW   |  j  sS t |  _  |  j j |  j  | rG |  j j rG |  j j   n  d |  _ n  d S(   sf  Close this ResultProxy.

        Closes the underlying DBAPI cursor corresponding to the execution.

        Note that any data cached within this ResultProxy is still available.
        For some types of results, this may include buffered rows.

        If this ResultProxy was generated from an implicit execution,
        the underlying Connection will also be closed (returns the
        underlying DBAPI connection to the connection pool.)

        This method is called automatically when:

        * all result rows are exhausted using the fetchXXX() methods.
        * cursor.description is None.

        N(   R   R   R   t   _safe_close_cursorR   t   should_close_with_resultt   closeR   (   R   t   _autoclose_connection(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    		c         c   s7   x0 t  r2 |  j   } | d  k r* t  q | Vq Wd  S(   N(   R   t   fetchoneR   t   StopIteration(   R   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR   "  s
    		c         C   sd   |  j  j s t j d   n< |  j  j s< t j d   n |  j  j rZ t j d   n  |  j  j S(   s  Return the primary key for the row just inserted.

        The return value is a list of scalar values
        corresponding to the list of primary key columns
        in the target table.

        This only applies to single row :func:`.insert`
        constructs which did not explicitly specify
        :meth:`.Insert.returning`.

        Note that primary key columns which specify a
        server_default clause,
        or otherwise do not qualify as "autoincrement"
        columns (see the notes at :class:`.Column`), and were
        generated using the database-side default, will
        appear in this list as ``None`` unless the backend
        supports "returning" and the insert statement executed
        with the "implicit returning" enabled.

        Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
        statement is not a compiled expression construct
        or is not an insert() construct.

        s1   Statement is not a compiled expression construct.s2   Statement is not an insert() expression construct.s9   Can't call inserted_primary_key when returning() is used.(   RW   t   compiledR    R)   R   t   _is_explicit_returningt   inserted_primary_key(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR   *  s    c         C   sd   |  j  j s t j d   nB |  j  j s< t j d   n$ |  j  j rR |  j  j S|  j  j d Sd S(   s  Return the collection of updated parameters from this
        execution.

        Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
        statement is not a compiled expression construct
        or is not an update() construct.

        s1   Statement is not a compiled expression construct.s2   Statement is not an update() expression construct.i    N(   RW   R   R    R)   t   isupdatet   executemanyt   compiled_parameters(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   last_updated_paramsU  s    	
c         C   sd   |  j  j s t j d   nB |  j  j s< t j d   n$ |  j  j rR |  j  j S|  j  j d Sd S(   s  Return the collection of inserted parameters from this
        execution.

        Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
        statement is not a compiled expression construct
        or is not an insert() construct.

        s1   Statement is not a compiled expression construct.s2   Statement is not an insert() expression construct.i    N(   RW   R   R    R)   R   R   R   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   last_inserted_paramsk  s    	
c         C   s
   |  j  j S(   s  Return the values of default columns that were fetched using
        the :meth:`.ValuesBase.return_defaults` feature.

        The value is an instance of :class:`.RowProxy`, or ``None``
        if :meth:`.ValuesBase.return_defaults` was not used or if the
        backend does not support RETURNING.

        .. versionadded:: 0.9.0

        .. seealso::

            :meth:`.ValuesBase.return_defaults`

        (   RW   t   returned_defaults(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c         C   s   |  j  j   S(   s   Return ``lastrow_has_defaults()`` from the underlying
        :class:`.ExecutionContext`.

        See :class:`.ExecutionContext` for details.

        (   RW   t   lastrow_has_defaults(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c         C   sT   |  j  j s t j d   n, |  j  j rJ |  j  j rJ t j d   n  |  j  j S(   sM  Return ``postfetch_cols()`` from the underlying
        :class:`.ExecutionContext`.

        See :class:`.ExecutionContext` for details.

        Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
        statement is not a compiled expression construct
        or is not an insert() or update() construct.

        s1   Statement is not a compiled expression construct.s>   Statement is not an insert() or update() expression construct.(   RW   R   R    R)   R   R   t   postfetch_cols(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c         C   sT   |  j  j s t j d   n, |  j  j rJ |  j  j rJ t j d   n  |  j  j S(   sL  Return ``prefetch_cols()`` from the underlying
        :class:`.ExecutionContext`.

        See :class:`.ExecutionContext` for details.

        Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
        statement is not a compiled expression construct
        or is not an insert() or update() construct.

        s1   Statement is not a compiled expression construct.s>   Statement is not an insert() or update() expression construct.(   RW   R   R    R)   R   R   t   prefetch_cols(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c         C   s
   |  j  j S(   sx   Return ``supports_sane_rowcount`` from the dialect.

        See :attr:`.ResultProxy.rowcount` for background.

        (   RX   t   supports_sane_rowcount(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c         C   s
   |  j  j S(   s~   Return ``supports_sane_multi_rowcount`` from the dialect.

        See :attr:`.ResultProxy.rowcount` for background.

        (   RX   t   supports_sane_multi_rowcount(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c         C   s3   y |  j  j   SWn t k
 r. |  j   n Xd  S(   N(   R   R   R.   t   _non_result(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   _fetchone_impl  s    c         C   sO   y- | d  k r |  j j   S|  j j |  SWn t k
 rJ |  j   n Xd  S(   N(   R   R   t	   fetchmanyR.   R   (   R   t   size(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   _fetchmany_impl  s    c         C   s3   y |  j  j   SWn t k
 r. |  j   n Xd  S(   N(   R   t   fetchallR.   R   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   _fetchall_impl  s    c         C   s4   |  j  d  k r! t j d   n t j d   d  S(   NsJ   This result object does not return rows. It has been closed automatically.s   This result object is closed.(   R   R   R    t   ResourceClosedError(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c   	      C   s   |  j  } |  j } | j } | j } |  j r |  j j j j } g  } x7 | D]/ } | d |  | j	 | | | | |   qL W| Sg  | D] } | | | | |  ^ q Sd  S(   Ns   Row %r(
   t   _process_rowR   R   R   Rh   RW   Ri   Rj   Rk   R'   (	   R   t   rowst   process_rowRl   R   R   t   logR,   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   process_rows  s    					 c         C   sc   y' |  j  |  j    } |  j   | SWn5 t k
 r^ } |  j j | d d |  j |  j  n Xd S(   s7   Fetch all rows, just like DB-API ``cursor.fetchall()``.N(	   R   R   R   R   R   R   R   R   RW   (   R   R,   R1   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR   	  s    
		c         C   s{   y? |  j  |  j |   } t |  d k r: |  j   n  | SWn5 t k
 rv } |  j j | d d |  j |  j	  n Xd S(   s   Fetch many rows, just like DB-API
        ``cursor.fetchmany(size=cursor.arraysize)``.

        If rows are present, the cursor remains open after this is called.
        Else the cursor is automatically closed and an empty list is returned.

        i    N(
   R   R   R    R   R   R   R   R   R   RW   (   R   R   R,   R1   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    			c         C   sz   y> |  j    } | d k	 r/ |  j | g  d S|  j   d SWn5 t k
 ru } |  j j | d d |  j |  j  n Xd S(   s   Fetch one row, just like DB-API ``cursor.fetchone()``.

        If a row is present, the cursor remains open after this is called.
        Else the cursor is automatically closed and None is returned.

        i    N(	   R   R   R   R   R   R   R   R   RW   (   R   R   R1   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR   (  s    
		c         C   s   |  j  d k r |  j   n  y |  j   } Wn5 t k
 rc } |  j j | d d |  j |  j  n Xz( | d k	 r |  j	 | g  d Sd SWd |  j
   Xd S(   sx   Fetch the first row and then close the result set unconditionally.

        Returns None if no row is present.

        i    N(   R   R   R   R   R   R   R   R   RW   R   R   (   R   R   R1   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   first;  s    		c         C   s(   |  j    } | d k	 r  | d Sd Sd S(   sx   Fetch the first column of the first row, and close the result set.

        Returns None if no row is present.

        i    N(   R   R   (   R   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   scalarS  s    N(+   R3   R4   RQ   R6   R   R   t   out_parametersR   t   _can_close_connectionR   R   R   RL   R   t   memoized_propertyR   t   propertyR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR   q  sD   	
		/		+			
															t   BufferedRowResultProxyc           B   s|   e  Z d  Z d   Z i d d 6d d 6d d 6d d 6d d 6d d 6d	 d 6d
 d	 6Z d   Z d   Z d d  Z d   Z	 RS(   sZ  A ResultProxy with row buffering behavior.

    ``ResultProxy`` that buffers the contents of a selection of rows
    before ``fetchone()`` is called.  This is to allow the results of
    ``cursor.description`` to be available immediately, when
    interfacing with a DB-API that requires rows to be consumed before
    this information is available (currently psycopg2, when used with
    server-side cursors).

    The pre-fetching behavior fetches only one row initially, and then
    grows its buffer size by a fixed amount with each successive need
    for additional rows up to a size of 100.
    c         C   s!   |  j    t t |   j   d  S(   N(   t$   _BufferedRowResultProxy__buffer_rowst   superR   R   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR   o  s    
i   i   i
   i   i2   id   i   i  i  c         C   sL   t  |  d d  } t j |  j j |   |  _ |  j j | |  |  _ d  S(   Nt   _bufsizei   (	   t   getattrt   collectionst   dequeR   R   t"   _BufferedRowResultProxy__rowbuffert   size_growthRc   R   (   R   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   __buffer_rows  s    c         C   s=   |  j  r d  S|  j s0 |  j   |  j s0 d  Sn  |  j j   S(   N(   R   R   R   R   t   popleft(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    		
	c         C   sc   | d  k r |  j   Sg  } x@ t d |  D]/ } |  j   } | d  k rN Pn  | j |  q, W| S(   Ni    (   R   R   R   R   R'   (   R   R   R   RV   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    
c         C   s5   |  j  j |  j j    |  j  } t j   |  _  | S(   N(   R   t   extendR   R   R   R   (   R   t   ret(    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    	N(
   R3   R4   RQ   R   R   R   R   R   R   R   (    (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR   `  s   	
			t   FullyBufferedResultProxyc           B   s>   e  Z d  Z d   Z d   Z d   Z d d  Z d   Z RS(   s   A result proxy that buffers rows fully upon creation.

    Used for operations where a result is to be delivered
    after the database conversation can not be continued,
    such as MSSQL INSERT...OUTPUT after an autocommit.

    c         C   s&   t  t |   j   |  j   |  _ d  S(   N(   R   R   R   t   _buffer_rowst$   _FullyBufferedResultProxy__rowbuffer(   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c         C   s   t  j |  j j    S(   N(   R   R   R   R   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    c         C   s   |  j  r |  j  j   Sd  Sd  S(   N(   R   R   R   (   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    	c         C   sc   | d  k r |  j   Sg  } x@ t d |  D]/ } |  j   } | d  k rN Pn  | j |  q, W| S(   Ni    (   R   R   R   R   R'   (   R   R   R   RV   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    
c         C   s   |  j  } t j   |  _  | S(   N(   R   R   R   (   R   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    	N(	   R3   R4   RQ   R   R   R   R   R   R   (    (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s   			t   BufferedColumnRowc           B   s   e  Z d    Z RS(   c         C   s   t  |  } d } x> | j D]3 } | d  k	 rE | | |  | | <n  | d 7} q Wt |  } t t |   j | | | |  d  S(   Ni    i   (   R   t   _orig_processorsR   R(   R   R   R   (   R   R   R   R   R   R+   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    (   R3   R4   R   (    (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s   t   BufferedColumnResultProxyc           B   s2   e  Z d  Z e Z d   Z d   Z d d  Z RS(   s  A ResultProxy with column buffering behavior.

    ``ResultProxy`` that loads all columns into memory each time
    fetchone() is called.  If fetchmany() or fetchall() are called,
    the full grid of results is fetched.  This is to operate with
    databases where result rows contain "live" results that fall out
    of scope unless explicitly fetched.  Currently this includes
    cx_Oracle LOB objects.

    c         C   s   t  t |   j   |  j } | j | _ g  t t | j   D] } d  ^ q> | _ i  } x9 | j
 j   D]( \ } \ } } } d  | | f | | <qi W| |  j _
 d  S(   N(   R   R   R   R   R   R   R   R    RL   R   R   RM   (   R   Rl   R   R   t   kt   funcR
   R+   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    	+%c         C   s@   g  } x3 t  r; |  j   } | d  k r+ Pn  | j |  q	 W| S(   N(   R   R   R   R'   (   R   R,   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    	c         C   s`   | d  k r |  j   Sg  } x= t |  D]/ } |  j   } | d  k rK Pn  | j |  q) W| S(   N(   R   R   R   R   R'   (   R   R   R,   Rp   R   (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s    
N(	   R3   R4   RQ   R   R   R   R   R   R   (    (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyR     s
   
		(   RQ   t    R    R   t   sqlR   R   R   R<   t   sqlalchemy.cresultproxyR   R   t   ImportErrorR   t   objectR6   RS   t   registerRT   R   R   R   R   R   (    (    (    s^   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/engine/result.pyt   <module>	   s4   >K B'