views:

2727

answers:

5

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

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.

Van Gale
I looked at tc and they dont have support for Table either. I think only Perl and Ruby bindings have full support for all bindings.
Bharani
+4  A: 

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.

Parand
+6  A: 

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

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

uggedal
i am sorry but the link doesn't work
Bharani
Due to my low points here I'm unable to submit links. Swap the hxxp with http to get it to work.
uggedal
+2  A: 

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.

Andy Mikhaylenko
By the way, all recent work is done in my fork of Pyrant: http://bitbucket.org/neithere/pyrant
Andy Mikhaylenko
+2  A: 

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

rsms