SQLite Shelf for Python
Allows an SQLite database to be used as a python dictionary
with persistant storage
Example
from sqliteshelf import SQLiteShelf, SQLiteDict
class Test:
def __init__(self):
self.foo = "bar"
# by default, things are stored in a "shelf" table
d = SQLiteShelf("test.sdb")
# you can put multiple shelves into a single SQLite database
e = SQLiteShelf("test.sdb", "othertable")
# both are empty to start with
print d
print e
# adding stuff is as simple as a regular dict
d['a'] = "moo"
e['a'] = "moo"
# regular dict actions work
print d['a']
print e['a']
print 'a' in d
del d['a']
print 'a' in d
# objects can be stored in shelves
t = Test()
d['t'] = t
print d['t']
If you only want to store strings as dictionary items, you can use SQLiteDict
to bypass the overhead of object pickling