Python Table engine binding for Tokyo Cabinet
Asked Answered
P

5

12

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?

Pompano answered 2/3, 2009 at 10:18 Comment(0)
S
7

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

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

Schreck answered 22/5, 2009 at 13:25 Comment(1)
Due to my low points here I'm unable to submit links. Swap the hxxp with http to get it to work.Schreck
E
4

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.

Emlin answered 8/4, 2009 at 22:41 Comment(0)
T
2

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.

Tungus answered 21/8, 2009 at 16:18 Comment(1)
By the way, all recent work is done in my fork of Pyrant: bitbucket.org/neithere/pyrantTungus
S
2

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

Sunbathe answered 6/10, 2009 at 15:46 Comment(0)
F
1

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.

Funicular answered 2/3, 2009 at 10:49 Comment(1)
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.Pompano

© 2022 - 2024 — McMap. All rights reserved.