Tokyo Tyrant backend
A storage/query backend for Tokyo Tyrant.
-
class pymodels.backends.tokyo_tyrant.Storage(host='127.0.0.1', port=1978)
-
clear()
- Clears the whole storage from data, resets autoincrement counters.
-
delete(key)
- Deleted record with given primary key.
-
get(model, primary_key)
- Returns model instance for given model and primary key.
Raises KeyError if there is no item with given key in the database.
-
save(model, data, primary_key=None)
Saves given model instance into the storage. Returns primary key.
Parameters: |
- model – model class
- data – dict containing all properties to be saved
- primary_key – the key for given object; if undefined, will be
generated
|
Note that you must provide current primary key for a model instance which
is already in the database in order to update it instead of copying it.
-
class pymodels.backends.tokyo_tyrant.Query(storage, model)
-
count()
- Returns the number of records that match current query. Does not fetch
the records.
-
delete()
- Deletes all records that match current query.
-
values(name)
- Returns a list of unique values for given column name.
-
where(**conditions)
- Returns Query instance filtered by given conditions.
The conditions are defined exactly as in Pyrant’s high-level query API.
See pyrant.query.Query.filter documentation for details.
-
where_not(**conditions)
- Returns Query instance. Inverted version of
where().