New in version 0.2.1.
Example:
from tokyocabinet import *
ndb = NDB()
# store records
for key, value in [("foo", "hop"), ("bar", "step"), ("baz", "jump")]:
ndb[key] = value
# retrieve one record
print(ndb["foo"])
# traverse records
for key in ndb:
print(key, ndb[key])
Note
For all methods taking either a key argument or a pair (key, value), key and value must be either str (Python2) or bytes (Python3).
See also
Methods keys(), values() and items() are not yet implemented (mainly because I didn’t settle on how to do it: should they return Iterable, Iterator, MappingView, etc.?). Any help would be greatly appreciated in this matter.
For the time being, for those of you who really need these methods, it’s trivial to implement them in python. Here is an example using generators:
from tokyocabinet import NDB as _NDB
class NDB(_NDB):
def keys(self):
return (key for key in self)
def values(self):
return (self[key] for key in self)
def items(self):
return ((key, self[key]) for key in self)