Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Py-elevator

py-elevator is a python client for Elevator, a Key-Value store written in Python and based on levelDB, allows high performance on-disk bulk read/write.

Allows async, multithreaded and/or remote access to a multi-leveldb backend.

Relying on the zeromq network library and msgpack serialization format, it is made to be portable between languages and platforms.

http://api.flattr.com/button/flattr-badge-large.png

Requirements

  • zmq-3.X

  • leveldb

  • pyzmq (built with zmq-3.X)

  • plyvel

Debian repository

The deb.oleiade.com debian repository exposes libzmq3, libzmq3-dev, libleveldb1 and libleveldb1-dev packages in order to ease your dependencies management. Just add the following line to your /etc/apt/sources.list:

deb http://deb.oleiade.com/debian oneiric main

Installation

Just:

pip install py-elevator

Usage

Nota : See Elevator documentation for details about server usage and implementation

Databases workaround

>>> from pyelevator import Elevator

# Elevator server holds a default db
# which the client will automatically
# connect to
>>> E = Elevator()
>>> E.db_name
'default'

# You can list remote databases
>>> E.listdb()
['default', ]

# Create a db
>>> E.createdb('testdb')
>>> E.listdb()
['default', 'testdb', ]

# And bind your client to that new Db.
>>> E.connect('testdb')

# Note that you canno't connect to a db that doesn't exist yet
>>> E.connect('dbthatdoesntexist')
DatabaseError : "Database does not exist"

# Sometimes, leveldb just messes up with the backend
# When you're done with a db, you can drop it. Note that all it's files
# will be droped too.
>>> E.repairdb()
>>> E.dropdb('testdb')


# You can even register a pre-existing leveldb db
# as an Elevator db. By creating it using it's path.
>>> E.createdb('/path/to/my/existing/leveldb')
>>> E.listdb()
['default', '/path/to/my/existing/leveldb', ]


# Elevator objects can also spawn WriteBatches objects,
# inheriting it's parent Elevator object configuration.
>>> batch = E.WriteBatch()

Interact with a database:

>>> from pyelevator import Elevator
>>> E = Elevator()                   # N.B : connected to 'default'

>>> E.Put('abc', '123')
>>> E.Put('easy as', 'do re mi')
>>> E.Get('abc')
'123'
>>> E.MGet(['abc', 'easy as', 'you and me'])
['123', 'do re mi', None]
>>> E.Delete('abc')
>>> for i in xrange(10):
...     E.Put(str(i), str(i))

# Range supports key_from, key_to params
>>> E.Range('1', '9')
[['1','1'],
 ['2','2'],
 ['3', '3'],
 ['4', '4'],
 ['5', '5'],
 ['6', '6'],
 ['7', '7'],
 ['8', '8'],
 ['9', '9'],
]

# Or key_from, limit params
>>> E.Slice('1', 2)
[['1', '1'],
 ['2', '2'],
]

# When RangeIter only knows about key_from/key_to for py-leveldb api
# compatibility reasons
>>> it = E.RangeIter('1', '2')
>>> list(it)
[['1', '1'],
 ['2', '2'],
]

# Elevator objects supports with_statement too
>>> with Elevator('testdb') as e:
>>> ....e.Get('1')
>>>
'1'

Batches

They’re very handy and very fast when it comes to write a lot of datas to the database. See LevelDB documentation for more informations. Use it through the WriteBatch client module class. It has three base methods modeled on LevelDB’s Put, Delete, Write.

>>> from pyelevator import WriteBatch, Elevator

# Just like Elevator object, WriteBatch connects to 'default' as a default
# But as it supports the exact same options that Elevator, you can
# Init it with a pre-existing db
>>> batch = WriteBatch()
>>> batch = WriteBatch('testdb')

>>> batch.Put('a', 'a')
>>> batch.Put('b', 'b')
>>> batch.Put('c', 'c')
>>> batch.Delete('c')
>>> batch.Write()

>>> E = Elevator()
>>> E.Get('a')
'a'
>>> E.Get('b')
'b'
>>> E.Get('c')
KeyError: "Key not found"

# Batches objects supports with_statement too
# Write will be automatically called on __exit__
>>> with WriteBatch('testdb') as batch:
>>> ....batch.Put('abc', '123')
>>> ....batch.Put('or simple as...', 'do re mi')
>>>

Code is clean and simple, don’t hesitate to dig into it if you need more details about it’s usage

Metadata

Release files for py-elevator 0.5c

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-elevator 0.5c
File Size Uploaded Provenance
py-elevator-0.5c.tar.gz 18.1 kB Without provenance Details

Release files / py-elevator-0.5c.tar.gz

Download URL py-elevator-0.5c.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9db738dbb7e2b1921fe040401e4868412eb292a4298864830b1d38d5dd5b229c
BLAKE2b-256 checksum
How to use checksums
d3b322e5eb428b49474f505b99db174f4f8325ac4ec3f1fa8db594e64f10e32f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for py-elevator 0.5c

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page