httk.db package

Submodules

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]
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]
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)[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]

httk.db.httkobjdbplugin module

class httk.db.httkobjdbplugin.HttkObjDbPlugin[source]

Bases: httk.core.httkobject.HttkPlugin

fetch_codependent_data(store)[source]
plugin_init(obj)[source]
store(store, avoid_duplicate=True)[source]
store_codependent_data(store)[source]

httk.db.storable module

class httk.db.storable.Storable(types=None, index=None)[source]

Bases: object

Superclass for handling various forms of data storage, retreival, etc. Class object representing data should inherit from Storable.

All public variables must be initalized in a call to storable_init() inside __init__(). Other member variables are OK, but must begin with ‘_’, and all methods must handle these variables not being initialized. For private variables that needs to be preserved: let them start with ‘_’ AND declare them in storable_init().

classmethod find_all(obj, store, member, value, types)[source]

Convinience method to do a very simple search of type: find all entries where member = value.

classmethod find_one(obj, store, member, value, types)[source]

Convinience^2 method to do a very simple search of type: find one entry where member = value.

storable_init(store, updatesid=None, **keyvals)[source]

All Storable objects need to call this method in __init__(). Name should be a ‘somewhat qualified’ class name.

trivialstore = <httk.db.storable.TrivialStore object>
classmethod variable(searcher, name, types, outid=None)[source]
class httk.db.storable.TrivialStore[source]

Bases: object

Very simple storage class that just stores everything into an individual dictionary, just like regular python objects work

new(table, types, keyvals)[source]
retrieve(table, types, sid)[source]
httk.db.storable.storable_props(*props)[source]
httk.db.storable.storable_types(name, *keyvals, **flags)[source]

Module contents