httk.db.filteredcollection module¶
-
class
httk.db.filteredcollection.DeclaredFunction(context, name, srctable=None)[source]¶ Bases:
object
-
class
httk.db.filteredcollection.FCDict(data=None)[source]¶ Bases:
httk.db.filteredcollection.FilteredCollectionThis implements a filtered collection purely backed by a dictionary and python evaluation.
Note: FCSqliteMemory will usually be faster. (However, you need this class if you need to express filters and expressions using python functions rather than Sqlite functions.)
-
data(outid=None)[source]¶ - Return an object where the attributes are accessible as properties. I.e.
- data = myFCDict.data myFCDict.set_filter(data.example == data.otherexample*2)
-
function(name)[source]¶ Define a python function object for use when expressing filter queries and column expressions. (You cannot define a filter with a “bare function”, since it would be called directly at the point of defining the filter.) Validy/existence of this function is not checked until the collection is iterated over.
-
-
class
httk.db.filteredcollection.FCMultiDict(data=None)[source]¶ Bases:
httk.db.filteredcollection.FilteredCollectionThis class allows you to combine a number of filtered collections and put filters on any combination of them together. Just create a separate FilteredCollection from each data source, and pass them in a list to the constructor of this class.
Filters that only apply to one of the FilteredCollections can be put on those collections instead, while a filter that applies to more than one must be set on this class.
-
add(filterexpr)[source]¶ Append a filter to the filters currently filtering the FilteredCollection. When iterating over the FilteredCollection, a result is only included if it matches all the filters.
-
data(name, outid=None)[source]¶ Return an object where the attributes of respective filtered collection is accessible as attributes. An example:
languagereview = FCMultiDict(‘programming’:programming_fc, ‘review’:review_fc) language = languagereview.data(‘programming’).language review = languagereview.data(‘review’) myFCMultiDict.set_filter(language.name == “python” & review.goodness > 9)
-
subdata(name, table, outid=None, key='rowid', subkey=None)[source]¶ Return an object where the attributes of respective filtered collection is accessible as attributes. An example:
languagereview = FCMultiDict(‘programming’:programming_fc, ‘review’:review_fc) language = languagereview.data(‘programming’).language review = languagereview.data(‘review’) myFCMultiDict.set_filter(language.name == “python” & review.goodness > 9)
-
-
class
httk.db.filteredcollection.FCMultiSqlite(dicts=None)[source]¶ Bases:
httk.db.filteredcollection.FilteredCollectionThis class allows you to combine a number of filtered collections and put filters on any combination of them together. Just create a separate FilteredCollection from each data source, and pass them in a list to the constructor of this class.
Filters that only apply to one of the FilteredCollections should preferably be put on those collections, while a filter that applies to more than one must be set on this class, using field definitions made with this class.
-
class
httk.db.filteredcollection.FCSqlite(sqlstore)[source]¶ Bases:
httk.db.filteredcollection.FilteredCollection-
function(name)[source]¶ Define a function object for expressing functions in filter queries. Validity/existence of this function may not be tested until an iteration over matching entries is performed.
-
-
class
httk.db.filteredcollection.FilteredCollection[source]¶ Bases:
objectMain interface for filtered collections.
Apart from what is declared here, each subclass should define e.g. ‘table’, ‘column’, ‘function’ methods for defining fields for use for filters (in, e.g., set_filter) and expressions (in, e.g., set_columns).
-
add(filterexpr)[source]¶ Append a filter to the filters currently filtering the FilteredCollection. When iterating over the FilteredCollection, a result is only included if it matches all the filters.
-
add_all(filterexpr)[source]¶ Append a filter to the filters currently filtering the FilteredCollection. When iterating over the FilteredCollection, a result is only included if it matches all the filters.
-
add_sort(expression, direction='ASC')[source]¶ Define which columns should be included in the results when iterating over a FilteredCollection. attributes is a list of tuples consisting of (name,definition) where definition can be any expression in columns.
Default is to show all columns of all tables defined. (See FilteredColleciton.table)
-
output(expression, name=None)[source]¶ Define which columns should be included in the results when iterating over a FilteredCollection. attributes is a list of tuples consisting of (name,definition) where definition can be any expression in columns.
Default is to show all columns of all tables defined. (See FilteredColleciton.table)
-
-
class
httk.db.filteredcollection.TableOrColumn(context, name, parent=None, outid=None, key=None, subkey=None, srctable=None, indirection=1, classref=None)[source]¶