Tokyo Cabinet Python bindings

Mar 2, 2009

Today I released tc – Python bindings to the Tokyo Cabinet database library. The code is heavily based on that of Tasuku Suenagas pytc and improves in many ways (documentation, code structure, python 2.6 and 3.0 compatibility, robust setup.py, etc).

It’s currently available for Python 2.4, 2.5, 2.6 and 3.0 in MacPorts and PyPI. Source resides in the ‘Hub.

Example

This assumes Mac OS X with MacPorts

$ sudo port sync
$ sudo port install py25-tc
$ python2.5

>>> import tc
>>> db = tc.HDB('casket.hdb', tc.HDBOWRITER | tc.HDBOCREAT)
>>> db.put('potato', 'potatis')
>>> db.put('carrot', 'morot')
>>> db.put('banana', 'banan')
>>> db.get('carrot')
'morot'