s.s.ResultSet(object) : class documentation

Part of storm.store View In Hierarchy

Implements interfaces: IResultSet

The representation of the results of a query.

Note that having an instance of this class does not indicate that a database query has necessarily been made. Database queries are put off until absolutely necessary.

Generally these should not be constructed directly, but instead retrieved from calls to Store.find.

Method __init__ Undocumented
Method copy Return a copy of this ResultSet object, with the same configuration.
Method config Configure this result object in-place. All parameters are optional.
Method __iter__ Iterate the results of the query.
Method __getitem__ Get an individual item by offset, or a range of items by slice.
Method __contains__ Check if an item is contained within the result set.
Method is_empty Return True if this result set doesn't contain any results.
Method any Return a single item from the result set.
Method first Return the first item from an ordered result set.
Method last Return the last item from an ordered result set.
Method one Return one item from a result set containing at most one item.
Method order_by Specify the ordering of the results.
Method remove Remove all rows represented by this ResultSet from the database.
Method group_by Group this ResultSet by the given expressions.
Method having Filter result previously grouped by.
Method count Get the number of objects represented by this ResultSet.
Method max Get the highest value from an expression.
Method min Get the lowest value from an expression.
Method avg Get the average value from an expression.
Method sum Get the sum of all values in an expression.
Method get_select_expr Get a Select expression to retrieve only the specified columns.
Method values Retrieve only the specified columns.
Method set Update objects in the result set with the given arguments.
Method cached Return matching objects from the cache for the current query.
Method find Perform a query on objects within this result set.
Method union Get the Union of this result set and another.
Method difference Get the difference, using Except, of this result set and another.
Method intersection Get the Intersection of this result set and another.
Method _get_select Undocumented
Method _load_objects Undocumented
Method _any Return a single item from the result without changing sort order.
Method _aggregate Undocumented
Method _set_expr Undocumented
def __init__(self, store, find_spec, where=Undef, tables=Undef, select=Undef):
Undocumented
def copy(self):
Return a copy of this ResultSet object, with the same configuration.
def config(self, distinct=None, offset=None, limit=None):
Configure this result object in-place. All parameters are optional.
ParametersdistinctBoolean enabling/disabling usage of the DISTINCT keyword in the query made.
offsetOffset where results will start to be retrieved from the result set.
limitLimit the number of objects retrieved from the result set.
Returnsself (not a copy).
def _get_select(self):
Undocumented
def _load_objects(self, result, values):
Undocumented
def __iter__(self):
Iterate the results of the query.
def __getitem__(self, index):
Get an individual item by offset, or a range of items by slice.
ReturnsThe matching object or, if a slice is used, a new ResultSet will be returned appropriately modified with OFFSET and LIMIT clauses.
def __contains__(self, item):
Check if an item is contained within the result set.
def is_empty(self):
Return True if this result set doesn't contain any results.
def any(self):
Return a single item from the result set.
ReturnsAn arbitrary object or None if one isn't available.
See Alsoone(), first(), and last().
def _any(self):
Return a single item from the result without changing sort order.
ReturnsAn arbitrary object or None if one isn't available.
def first(self):
Return the first item from an ordered result set.
ReturnsThe first object or None if one isn't available.
RaisesUnorderedErrorRaised if the result set isn't ordered.
See Alsolast(), one(), and any().
def last(self):
Return the last item from an ordered result set.
ReturnsThe last object or None if one isn't available.
RaisesFeatureErrorRaised if the result set has a LIMIT set.
UnorderedErrorRaised if the result set isn't ordered.
See Alsofirst(), one(), and any().
def one(self):
Return one item from a result set containing at most one item.
ReturnsThe object or None if one isn't available.
RaisesNotOneErrorRaised if the result set contains more than one item.
See Alsofirst(), one(), and any().
def order_by(self, *args):
Specify the ordering of the results.

The query will be modified appropriately with an ORDER BY clause.

Ascending and descending order can be specified by wrapping the columns in Asc and Desc.

ParametersargsOne or more storm.expr.Column objects.
def remove(self):
Remove all rows represented by this ResultSet from the database.

This is done efficiently with a DELETE statement, so objects are not actually loaded into Python.

def group_by(self, *expr):
Group this ResultSet by the given expressions.
ParametersexprThe expressions used in the GROUP BY statement.
Returnsself (not a copy).
def having(self, *expr):
Filter result previously grouped by.
ParametersexprInstances of Expr.
Returnsself (not a copy).
def _aggregate(self, aggregate_func, expr, column=None):
Undocumented
def count(self, expr=Undef, distinct=False):
Get the number of objects represented by this ResultSet.
def max(self, expr):
Get the highest value from an expression.
def min(self, expr):
Get the lowest value from an expression.
def avg(self, expr):
Get the average value from an expression.
def sum(self, expr):
Get the sum of all values in an expression.
def get_select_expr(self, *columns):
Get a Select expression to retrieve only the specified columns.
ParameterscolumnsOne or more storm.expr.Column objects whose values will be fetched.
ReturnsA Select expression configured to use the query parameters specified for this result set, and also limited to only retrieving data for the specified columns.
RaisesFeatureErrorRaised if no columns are specified or if this result is a set expression such as a union.
def values(self, *columns):
Retrieve only the specified columns.

This does not load full objects from the database into Python.

ParameterscolumnsOne or more storm.expr.Column objects whose values will be fetched.
ReturnsAn iterator of tuples of the values for each column from each matching row in the database.
RaisesFeatureErrorRaised if no columns are specified or if this result is a set expression such as a union.
def set(self, *args, **kwargs):
Update objects in the result set with the given arguments.

This method will update all objects in the current result set to match expressions given as equalities or keyword arguments. These objects may still be in the database (an UPDATE is issued) or may be cached.

For instance, result.set(Class.attr1 == 1, attr2=2) will set attr1 to 1 and attr2 to 2, on all matching objects.

def cached(self):
Return matching objects from the cache for the current query.
def find(self, *args, **kwargs):
Perform a query on objects within this result set.

This is analogous to Store.find, although it doesn't take a cls_spec argument, instead using the same tables as the existing result set, and restricts the results to those in this set.

ParametersargsInstances of Expr.
kwargsMapping of simple column names to values or expressions to query for.
ReturnsA ResultSet of matching instances.
def _set_expr(self, expr_cls, other, all=False):
Undocumented
def union(self, other, all=False):
Get the Union of this result set and another.
ParametersallIf True, include duplicates.
def difference(self, other, all=False):
Get the difference, using Except, of this result set and another.
ParametersallIf True, include duplicates.
def intersection(self, other, all=False):
Get the Intersection of this result set and another.
ParametersallIf True, include duplicates.
API Documentation for storm, generated by pydoctor at 2011-03-15 08:53:51.