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?
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:
If this doesn't work you are probably out of luck. I think all the tyrant bindings only use the hash engine.
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.
Here is an implementation of search of table engine using PyTyrant:
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.
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