def get_events(self, from_=None, to=None):
        """Query a slice of the events.

        Events are always returned in the order the were added.

        Parameters:
        from_   -- if not None, return only events added after the event with
                   id `from_`. If None, return from the start of history.
        to      -- if not None, return only events added before, and
                   including, the event with event id `to`. If None, return up
                   to, and including, the last added event.

        returns -- an iterable of (event id, eventdata) tuples.

        """
        assert from_ is None or isinstance(from_, str)
        assert to is None or isinstance(to, str)
        if from_ and not self.key_exists(from_):
            msg = 'from_={0}'.format(from_)
            raise EventStore.EventKeyDoesNotExistError(msg)
        if to and not self.key_exists(to):
            msg = 'to={0}'.format(to)
            raise EventStore.EventKeyDoesNotExistError(msg)

        # +1 below because we have already seen the event
        fromindex = self._get_eventid(from_) + 1 if from_ else 0
        toindex = self._get_eventid(to) if to else None
        if from_ and to and fromindex > toindex:
            raise EventOrderError("'to' happened cronologically before"
                                  " 'from_'.")

        if toindex:
            sql = ('SELECT uuid, event FROM events '
                   'WHERE eventid BETWEEN ? AND ?')
            params = (fromindex, toindex)
        else:
            sql = 'SELECT uuid, event FROM events WHERE eventid >= ?'
            params = (fromindex,)
        sql = sql + " ORDER BY eventid"
        return [(row[0], row[1].encode('utf-8'))
                for row in self.conn.execute(sql, params)]
def get_events ( self , from_ = None , to = None ) : assert from_ is None or isinstance ( from_ , str ) assert to is None or isinstance ( to , str ) if from_ and not self . key_exists ( from_ ) : msg = 'from_={0}' . format ( from_ ) raise EventStore . EventKeyDoesNotExistError ( msg ) if to and not self . key_exists ( to ) : msg = 'to={0}' . format ( to ) raise EventStore . EventKeyDoesNotExistError ( msg ) fromindex = self . _get_eventid ( from_ ) + 1 if from_ else 0 toindex = self . _get_eventid ( to ) if to else None if from_ and to and fromindex > toindex : raise EventOrderError ( "'to' happened cronologically before" " 'from_'." ) if toindex : sql = ( 'SELECT uuid, event FROM events ' 'WHERE eventid BETWEEN ? AND ?' ) params = ( fromindex , toindex ) else : sql = 'SELECT uuid, event FROM events WHERE eventid >= ?' params = ( fromindex , ) sql = sql + " ORDER BY eventid" return [ ( row [ 0 ] , row [ 1 ] . encode ( 'utf-8' ) ) for row in self . conn . execute ( sql , params ) ]
Query a slice of the events.

        Events are always returned in the order the were added.

        Parameters:
        from_   -- if not None, return only events added after the event with
                   id `from_`. If None, return from the start of history.
        to      -- if not None, return only events added before, and
                   including, the event with event id `to`. If None, return up
                   to, and including, the last added event.

        returns -- an iterable of (event id, eventdata) tuples.