wepy.util.kv module

Implement a key-value store on top of sqlite3 database.

wepy.util.kv.gen_uri(db_url, mode_spec)[source]
class wepy.util.kv.KV(db_url=None, table='data', primary_key='key', value_name='value', timeout=5, mode='x', append_only=False, value_types=(<class 'bytes'>, <class 'bytearray'>))[source]

Bases: collections.abc.MutableMapping

property mode
property append_only
close()[source]
property db_uri
property db
property table
property primary_key
property value_name
property value_types
_execute(*args)[source]
property insert_query
property update_query
property del_query
lockless_set(key, value)[source]

an implementation of the __setitem__ without the lock context manager which turns on the DEFERRED isolation level. The isolation level of the KV is set to autocommit so now lock is needed anyhow.

set_in_tx(cursor, key, value)[source]

Do a set with a cursor, this allows it to be done in a transaction.

del_in_tx(cursor, key)[source]
lock()[source]
_abc_impl = <_abc_data object>
clear()None.  Remove all items from D.
get(k[, d])D[k] if k in D, else d.  d defaults to None.
items()a set-like object providing a view on D’s items
keys()a set-like object providing a view on D’s keys
pop(k[, d])v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()(k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d])D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F)None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()an object providing a view on D’s values