httk.db.filteredcollection module

class httk.db.filteredcollection.BinaryBooleanOp(context, operator, left, right)[source]

Bases: httk.db.filteredcollection.Expression

class httk.db.filteredcollection.BinaryComparison(context, operator, left, right)[source]

Bases: httk.db.filteredcollection.Expression

class httk.db.filteredcollection.BinaryOp(context, operator, left, right)[source]

Bases: httk.db.filteredcollection.Expression

class httk.db.filteredcollection.DeclaredFunction(context, name, srctable=None)[source]

Bases: object

class httk.db.filteredcollection.Expression(context, exprtype, *args)[source]

Bases: object

get_srctable_context()[source]
is_in(*args)[source]
like(*args)[source]
class httk.db.filteredcollection.FCDict(data=None)[source]

Bases: httk.db.filteredcollection.FilteredCollection

This 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.)

copy()[source]
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.FilteredCollection

This 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.

copy()[source]
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.FilteredCollection

This 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.

sql()[source]
store_table(name)[source]

Store the result of the filtered collection in a new table named ‘name’.

subtable(name, table, outid=None, key='rowid', subkey=None)[source]

Defines a table object to use in filters (for add) and expressions (in set_columns).

table(name, outid=None)[source]

Defines a table object to use in filters (for add) and expressions (in set_columns).

class httk.db.filteredcollection.FilteredCollection[source]

Bases: object

Main 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)

duplicate(other)[source]
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)

reset()[source]

Clear any filtering done on the data source.

store_table(name)[source]

Store the result of the filtered collection in a new table named ‘name’.

variable(obj, outid=None, parent=None, parentkey=None, subkey=None)[source]
class httk.db.filteredcollection.Function(context, name, srctable, *args)[source]

Bases: httk.db.filteredcollection.Expression

class httk.db.filteredcollection.TableOrColumn(context, name, parent=None, outid=None, key=None, subkey=None, srctable=None, indirection=1, classref=None)[source]

Bases: httk.db.filteredcollection.Expression

class httk.db.filteredcollection.UnaryBooleanOp(context, operator, right)[source]

Bases: httk.db.filteredcollection.Expression

httk.db.filteredcollection.fc_checkcontext(context, *exprs)[source]
httk.db.filteredcollection.fc_eval(expr, data)[source]
httk.db.filteredcollection.fc_get_srctable_context(*args)[source]
httk.db.filteredcollection.fc_sql(expr)[source]
httk.db.filteredcollection.instantiate_from_store(classobj, store, id)[source]