Python Table engine binding for Tokyo Cabinet

和自甴很熟 提交于 2019-11-29 07:29:33

问题


I am looking for python bindings for Table engine of Tokyo cabinet. I tried Pytc but can only find Hash and B-tree engine support. Is there any other bindings available?


回答1:


Here is an implementation of search of table engine using PyTyrant:

http://github.com/ericflo/pytyrant/tree/master




回答2:


I was in contact with the author of tc and he told me the following:

Currently, the table (tdb) driver exist in the master branch (unit tests) and the fdb driver is being developed in a separate branch.

I tried the table driver for a small test with success, am planning on trying it on larger tables soon.




回答3:


My branch of pytc called "tc" do have support for tables (TDB) http://github.com/rsms/tc

Basic example:

>>> 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

Performing queries:

>>> 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']

More examples in the TDB unit test: http://github.com/rsms/tc/blob/master/lib/tc/test/tdb.py




回答4:


I've been monitoring (and sometimes improving) various Python bindings for TC for more than a year, so here's an updated list of best bindings matching your criteria.

  • For Tokyo Cabinet, including Tyrant: tokyo-python
  • For Tokyo Tyrant (pure-Python): pyrant

There are many stale and/or incomplete alternatives.




回答5:


The only other one I know of is a fork of pytc but it looks like they have only done some refactoring and documentation work, so probably still only hash and b-tree support:

tc

If this doesn't work you are probably out of luck. I think all the tyrant bindings only use the hash engine.



来源:https://stackoverflow.com/questions/601865/python-table-engine-binding-for-tokyo-cabinet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!