Part of vmc.contrib.axiom.store View In Hierarchy
Known subclasses: vmc.contrib.axiom.store.AttributeQuery, vmc.contrib.axiom.store.ItemQuery, vmc.contrib.axiom.store.MultipleItemQuery
Implements interfaces: vmc.contrib.axiom.iaxiom.IQuery
This is the abstract base implementation of query logic shared between item and attribute queries.
Note: as this is an abstract class, it doesn't *actually* implement IQuery, but all its subclasses must, so it is declared to. Don't instantiate it directly.Method | __init__ | Create a generic object-oriented interface to SQL, used to implement |
Method | cloneQuery | Create a similar-but-not-identical copy of this query with certain |
Method | __repr__ | Undocumented |
Method | explain | A debugging API, exposing SQLite's 'EXPLAIN' statement. |
Method | locateCallSite | Undocumented |
Method | distinct | Call this method if you want to avoid repeated results from a query. |
Method | __iter__ | Iterate the results of this query. |
Method | next | This method is deprecated, a holdover from when queries were iterators, |
Parameters | store | the store that this query is within. |
tableClass | a subclass of Item .
| |
comparison | an implementor of iaxiom.IComparison
| |
limit | an int that limits the number of results that will be
queried for, or None to indicate that all results should be returned.
| |
offset | an int that specifies the offset within the query results
to begin iterating from, or None to indicate that we should start at 0.
| |
sort | A sort order object. Obtained by doing
YourItemClass.yourAttribute.ascending or
.descending .
|
Create a similar-but-not-identical copy of this query with certain attributes changed.
(Currently this only supports the manipulation of the "limit" parameter, but it is the intent that with a richer query-introspection interface, this signature could be expanded to support many different attributes.)Parameters | limit | an integer, representing the maximum number of rows that this query should return. |
Returns | an IQuery
provider with the new limit.
|
A debugging API, exposing SQLite's 'EXPLAIN' statement. While this is not a private method, you also probably don't have any use for it unless you understand this page very well: http://www.sqlite.org/opcode.html Once you do, it can be handy to call this interactively to get a sense of the complexity of a query. @return: a list, the first element of which is a L{str} (the SQL statement which will be run), and the remainder of which is 3-tuples resulting from the 'EXPLAIN' of that statement.
Return a generator which yields the massaged results of this query with a particular SQL verb.
For an attribute query, massaged results are of the type of that attribute. For an item query, they are items of the type the query is supposed to return.Parameters | verb | a str containing the SQL verb to execute. This really must be some variant of 'SELECT', the only two currently implemented being 'SELECT' and 'SELECT DISTINCT'. |
Parameters | row | a tuple of some kind, representing an element of data returned from a call to sqlite. |
Call this method if you want to avoid repeated results from a query. You can call this on either an attribute or item query. For example, on an attribute query:: X(store=s, value=1, name=u'foo') X(store=s, value=1, name=u'bar') X(store=s, value=2, name=u'baz') X(store=s, value=3, name=u'qux') list(s.query(X).getColumn('value')) => [1, 1, 2, 3] list(s.query(X).getColumn('value').distinct()) => [1, 2, 3] You can also use distinct queries to eliminate duplicate results from joining two Item types together in a query, like so: x = X(store=s, value=1, name=u'hello') Y(store=s, other=x, ident=u'a') Y(store=s, other=x, ident=u'b') Y(store=s, other=x, ident=u'b+') list(s.query(X, AND(Y.other == X.storeID, Y.ident.startswith(u'b')))) => [X(name=u'hello', value=1, storeID=1)@..., X(name=u'hello', value=1, storeID=1)@...] list(s.query(X, AND(Y.other == X.storeID, Y.ident.startswith(u'b'))).distinct()) => [X(name=u'hello', value=1, storeID=1)@...] @return: an L{iaxiom.IQuery} provider whose values are distinct.