1
I Use This!
Activity Not Available

Project Summary

A pythonic python-only implementation of Tokyo Tyrant protocol. Table extension and query operations are also implementend. Python 2.4+ is needed

This library takes a "pythonic" approach to make it more clear and easy to implement. This code is based on pytyrant

More information about Tokyo Cabinet:

http://tokyocabinet.sourceforge.net/

More information about Tokyo Tyrant:

http://tokyocabinet.sourceforge.net/tyrantdoc/

Hash DatabaseUsing hash database is like using dictionaries on python with some extra features. (You can see the docstrings to learn all the features)

>>> import pyrant
>>> t = pyrant.Tyrant(host='127.0.0.1', port=1978)
>>> t['key'] = 'foo'
>>> print t['key']
foo
>>> t.concat('key', 'bar')
>>> print t['key']
foobar
>>> 'key' in t
True
>>> del t['key']
>>> print t['key']
Traceback (most recent call last):
...
KeyError: 'key'Table Databasepyrant supports table records and query operations. To insert a record just use as before but set a dictionary as value.

Table record example

>>> from pyrant import Tyrant, Q
>>> t = Tyrant(host='127.0.0.1', port=1978)
>>> t['i'] = {'name': 'Martin Conte Mac Donell', 'gender': 'M', 'age': 26}
>>> t['you'] = {'name': 'Guido', 'gender': 'M', 'age': 33}
>>> print t['i']
{'name': 'Martin Conte Mac Donell', 'gender': 'M'}FilterYou can query elements using lazy filters. Every filter is added using "AND" operator, if you want to "OR" some field, you should use Q object (see below).

Keys that you can use in queries are:

__eq: Equals (default) to expression __lt: Less than expression __le: Less or equal to expression __gt: Greater than expression __ge: Greater or equal to expression Query filter example code

>>> res = t.query.filter(gender='M') # Query is not done yet
>>> res # Here query is performed
[{'i': {'gender': 'M', 'age': '26', 'name': 'Martin Conte Mac Donell'}}, {'you': {'gender': 'M', 'age': '33', 'name': 'Guido'}}]Query example using Q

>>> res = t.query.filter(gender='M') # Query is not done yet
>>> res = res.filter(Q(age=26) | Q(age=33)) # Query is not done yet
>>> print res # Here query is performed
[{'i': {'gender': 'M', 'age': '26', 'name': 'Martin Conte Mac Donell'}}, {'you': {'gender': 'M', 'age': '33', 'name': 'Guido'}}]OrderOrdering elements are another great feature. It is used to define result order.

Name parameter is the column name, also you can prefix "-" to order desc. If "#" is added just before column name, column are ordered as numbers

Examples: order('-name') order('-#ranking') order('name')

Order example code

# You can order using:
>>> res.order('#age') # New query is performed
[{'i': {'gender': 'M', 'age': '26', 'name': 'Martin Conte Mac Donell'}}, {'you': {'gender': 'M', 'age': '33', 'name': 'Guido'}}]
>>> res.order('-#age') # New query is performed
[{'you': {'gender': 'M', 'age': '33', 'name': 'Guido'}}, {'i': {'gender': 'M', 'age': '26', 'name': 'Martin Conte Mac Donell'}}]Limit / OffsetYou can also subscript Query objects to limit or offset your results.

Limit example code

>>> res[1:2]
[{'i': {'gender': 'M', 'age': '26', 'name': 'Martin Conte Mac Donell'}}]

Tags

cabinet python pythonic tokyo tokyocabinet tyrant

In a Nutshell, pyrant...

 Code analysis has not completed

The Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. The source code for this project has been located, but the analysis isn't complete. Feel free to check its progress.
Apache License 2.0
Permitted

Commercial Use

Modify

Distribute

Place Warranty

Sub-License

Private Use

Use Patent Claims

Forbidden

Hold Liable

Use Trademarks

Required

Include Copyright

State Changes

Include License

Include Notice

These details are provided for information only. No information here is legal advice and should not be used as such.

Project Security

Vulnerabilities per Version ( last 10 releases )

There are no reported vulnerabilities

Project Vulnerability Report

Security Confidence Index

Poor security track-record
Favorable security track-record

Vulnerability Exposure Index

Many reported vulnerabilities
Few reported vulnerabilities

Did You Know...

  • ...
    there are over 3,000 projects on the Open Hub with security vulnerabilities reported against them
  • ...
    you can subscribe to e-mail newsletters to receive update from the Open Hub blog
  • ...
    in 2016, 47% of companies did not have formal process in place to track OS code
  • ...
    search using multiple tags to find exactly what you need
About Project Security

 Code analysis has not completed

The Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. The source code for this project has been located, but the analysis isn't complete. Feel free to check its progress.

Community Rating

1 user rates this project:
5.0
 
5.0/5.0
Click to add your rating
  
Review this Project!