Async, exception-free key-value store ABC. Implementations over SQLAlchemy, the filesystem, Redis, Azure Blob, and more.
Project description
KV
Async, exception-free key-value store ABC. Implementations over SQLAlchemy, the filesystem, Redis, Azure Blob, and more.
pip install python-kv
Usage
from kv import KV
kv = KV.of('sql+sqlite:///path/to/db.sqlite') # easiest way to switch backends: connection strings
await kv.insert('key', 'value') # Left[DBError] | Right[None]
await kv.read('key') # Left[ReadError] | Right['value']
await kv.delete('key') # Left[DBError] | Right[None]
[k async for k in kv.keys()] # list[Left[ReadError] | Right[T]]
[it async for it in kv.items()] # list[Left[ReadError] | Right[tuple[str, T]]]
await kv.clear() # Left[DBError] | Right[None]
# and a few more
Serialization & Validation
from dataclasses import dataclass
@dataclass
class MySerializableType:
a: int
b: str
kv = KV.of('sql+sqlite://...', MySerializableType)
await kv.insert('key', MySerializableType(1, '2')) # Left[InvalidData] | Right[None]
# etc.
CLI
kv serve 'file://data' --token "shhhhh" --port 8080 --type dict
kv serve 'sql+postgresql+psycop2g://...' --port 8081 --type str
kv copy -i 'file://data' -o 'sql+sqlite:///path/to/db.sqlite' -v
kv copy -i 'https://my.com/data' -o 'sql+sqlite:///path/to/db.sqlite'
</code></pre>
<pre lang="bash"><code>kv test CONN_STR # runs some basic tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python_kv-0.2.2.tar.gz
(16.3 kB
view details)
Built Distribution
python_kv-0.2.2-py3-none-any.whl
(23.0 kB
view details)
File details
Details for the file python_kv-0.2.2.tar.gz
.
File metadata
- Download URL: python_kv-0.2.2.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f31a7bb786879f820ee605fc4ecfe0bb3d2d22e995b2a82b5256c29557a9ffb |
|
MD5 | dbdc631d5df165848351be3ffc202d22 |
|
BLAKE2b-256 | a97b233c233f35bf5e16ddba721140b75f2cf11608ca07c93fe21ad27807dfe1 |
File details
Details for the file python_kv-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: python_kv-0.2.2-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 287d457fbc346133069bd3fa7a2b093db05d6984568e0941be22bfc5dfb42600 |
|
MD5 | 1493dfce7b1394a723bc0b8a5eb40340 |
|
BLAKE2b-256 | 1d287853298541ad8fc87cb5afeea57ced1c7d3a5ac6cfb7a67faa415a3a8f13 |