Registry / database / simplekv

simplekv

JSON →
library0.14.1pypypi✓ verified 83d ago

A key-value store for binary data, supporting multiple backends including filesystem, Redis, MongoDB, Azure Blob Storage, and Amazon S3. Current version: 0.14.1. Release cadence is irregular, with occasional minor and patch releases.

pip install simplekv
INSTALL
IMPORT
SIG · SIMPLEKV
S
simplekv
databasepythonv0.14.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

KeyValueStore
from simplekv import KeyValueStore
Base class for all stores.
RedisStore
from simplekv.contrib.redis import RedisStore
Redis backend store.
S3Store
from simplekv.contrib.s3 import S3Store
Amazon S3 backend store (boto3).
FilesystemStore
from simplekv.fs import FilesystemStore
Local filesystem backend.
MongoStore
from simplekv.contrib.mongo import MongoStore
MongoDB backend.
AzureBlockBlobStore
from simplekv.contrib.azure import AzureBlockBlobStore
Azure Blob Storage backend (since 0.14.0).

Basic usage of RedisStore.

import os from simplekv.contrib.redis import RedisStore # Initialize store (assuming Redis running on localhost) store = RedisStore(host='localhost', port=6379) # Put a value store.put('key', b'value') # Get a value value = store.get('key') print(value) # Delete a value store.delete('key')
Debug
Known issues
gotchaThe `keys()` method returns a generator in Python 3 (since 0.12.0), not a list. This is a change from earlier versions where it returned a list. Wrap with `list()` if you need a list.
fix
Use `list(store.keys())` to get a list.
affects: >=0.12.0
breakingIn version 0.14.0, the Azure backend switched to `azure-storage-blob` version 12. Old code using the old Azure SDK will break. The store class name is now `AzureBlockBlobStore`.
fix
Update dependencies to `azure-storage-blob>=12` and import `AzureBlockBlobStore`.
affects: >=0.14.0
gotchaThe `S3Store`'s `open()` method removed seek/tell support in version 0.11.7 due to leaking HTTP connections. If you rely on random access on S3 file-like objects, this will break.
fix
Do not use `seek()` or `tell()` on S3Store opened files; read sequentially or download the entire object.
affects: >=0.11.7
Errors
Common errors & fixes
ImportError: No module named 'simplekv.contrib.redis'
The `redis` extra dependency is missing.
fix
Install simplekv with redis support: `pip install simplekv[redis]`
AttributeError: 'generator' object has no attribute 'sort'
`keys()` now returns a generator instead of a list (since 0.12.0).
fix
Convert to list: `list(store.keys()).sort()`
TypeError: can't pickle 'generator' objects
Trying to pickle the result of `keys()` (a generator) in multiprocessing context.
fix
Convert to list before passing to other processes: `list(store.keys())`
Upgrade
Version history
0.14.1latest on PyPI · released Apr 9, 2020
Audit
Dependencies
redisoptionalRequired for RedisStore backend when using simplekv[redis]
boto3optionalRequired for S3 backend when using simplekv[s3]
azure-storage-bloboptionalRequired for Azure backend; version 12+ supported since simplekv 0.14.0
pymongooptionalRequired for MongoDB backend when using simplekv[mongo]
Agent activity
14 hits · last 30 days
node
12
Meta
1
Resources
simplekv — pip install simplekv · libregistry