我正在寻找Tokyo Cabinet 的表引擎的Python绑定。我尝试了 Pytc,但只能找到Hash和B-tree引擎的支持。是否有其他可用的绑定?
http://github.com/ericflo/pytyrant/tree/master
我的 pytc 分支名为 "tc",支持表格(TDB)http://github.com/rsms/tc
基本示例:
>>> import tc
>>> db = tc.TDB("slab.tdb", tc.TDBOWRITER | tc.TDBOCREAT)
>>> db.put('some key', {'name': 'John Doe', 'age': '45', 'city': u'Internets'})
>>> rec = db.get('some key')
>>> print rec['name']
John Doe
执行查询:
>>> import tc
>>> db = tc.TDB("slab.tdb", tc.TDBOWRITER | tc.TDBOCREAT)
>>> db.put('torgny', {'name': 'Torgny Korv', 'age': '31', 'colors': 'red,blue,green'})
>>> db.put('rosa', {'name': 'Rosa Flying', 'age': '29', 'colors': 'pink,blue,green'})
>>> db.put('jdoe', {'name': 'John Doe', 'age': '45', 'colors': 'red,green,orange'})
>>> q = db.query()
>>> q.keys()
['torgny', 'rosa', 'jdoe']
>>> q.filter('age', tc.TDBQCNUMGE, '30')
>>> q.keys()
['torgny', 'jdoe']
>>> q.filter('colors', tc.TDBQCSTROR, 'blue')
>>> q.keys()
['torgny']
>>> # new query:
>>> q = db.query()
>>> q.order('name') # Ascending order by default
>>> q.keys()
['jdoe', 'rosa', 'torgny']
>>> q.order(type=tc.TDBQONUMASC, column='age')
>>> q.keys()
['jdoe', 'torgny', 'rosa']
在TDB单元测试中有更多的示例:http://github.com/rsms/tc/blob/master/lib/tc/test/tdb.py
我已经监控(有时还改善)了一年多的TC的各种Python绑定,因此这里是更新后的最佳绑定列表,符合您的标准。
有许多过时和/或不完整的替代方案。