Skip to main content

pyopenkeyval

OpenKeyval.org is a service for easily storing and retrieving key/value pairs via HTTP. pyopenkeyval is a Python interface to this service, presented as a dict-like object that accesses data on OpenKeyval.

Installing

$ sudo python setup.py install

Examples

Normal usage

from pyopenkeyval import pyopenkeyval
okv = pyopenkeyval()
okv['example'] = 'Hello, online key/value storage!'
print okv['example']

If you need the result from storing a value, use the store() method instead:

result = okv.store('example', 'Hello, online key/value storage!')
print result['read_only_key']

To check if a key has a value, use the in keyword. Note that this will also cache the value if caching is activated.

if 'example' in okv:
     ...

Deleting keys

To delete a key, either set its value to ‘’ or use the del keyword:

del okv['example']

Caching

If you want to cache retrieved values locally, set the cache_time argument when constructing the pyopenkeyval object. This specifies the number of seconds to cache individual values.

okv = pyopenkeyval(cache_time=60)

To clear the cache completely at any time, call the clear_cache() method.

SSL support

OpenKeyval.org also supports SSL over HTTPS for more secure transfer of data. To use SSL, set the ssl argument to True.

okv = pyopenkeyval(ssl=True)

Note that the HTTP och HTTPS versions of OpenKeyval.org are completely separate. Values set in one can’t be fetched from the other.

Python 3

pyopenkeyval is since version 0.3 compatible with Python 3. It must, however, either be installed using setup.py (as described above) before use, or manually be converted using the 2to3 tool.

Also note that values fetched will be returned as bytes. To use these as strings, call the .decode() method on them first. When setting values, either str or bytes can be used.

Requirements

Python 2.5 and lower require simplejson to be installed.

Metadata

Release files for pyopenkeyval 0.4

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

Source distribution (sdist)

Source distribution for pyopenkeyval 0.4
File Size Uploaded
pyopenkeyval-0.4.tar.gz 1.6 kB Details

Release files / pyopenkeyval-0.4.tar.gz

Download URL pyopenkeyval-0.4.tar.gz
Size 1.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a5a06e852fed562e49fc8c2d6bbfc1a923aa3518f19c4771d0c8f2f6e18acd0f
BLAKE2b-256 checksum
How to use checksums
306a4db7aa0fe429aa5145a6e08fec0d5810c8cfc53b8afcdccb941fded4f993
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4 This release

1 release file

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