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'
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.12.tar.gz
(19.1 kB
view details)
Built Distribution
File details
Details for the file python_kv-0.2.12.tar.gz
.
File metadata
- Download URL: python_kv-0.2.12.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3028cdb802aacb0b6efb9c9bdb845fd8ccac7b7d2856cb27065eacd3a2e7176b |
|
MD5 | 9deafb7fa22a560e20405f5e217db175 |
|
BLAKE2b-256 | 8c6c1f739a25ba3fee7de1b091a42e2ad919dda0d42f2a87685e8a0abb48a8dc |
File details
Details for the file python_kv-0.2.12-py3-none-any.whl
.
File metadata
- Download URL: python_kv-0.2.12-py3-none-any.whl
- Upload date:
- Size: 28.7 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 | 2e3f1362f8c57bc5479db5c5ed82d0957682900a21404532c2a5a31f23014462 |
|
MD5 | f74e5ab3df78946bfb1192e59b4da156 |
|
BLAKE2b-256 | 626b997973eba44fc38345d90b554d5ad29374989900a8e5dddfce368f5f3b52 |