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.4.tar.gz
(17.5 kB
view details)
Built Distribution
python_kv-0.2.4-py3-none-any.whl
(25.1 kB
view details)
File details
Details for the file python_kv-0.2.4.tar.gz
.
File metadata
- Download URL: python_kv-0.2.4.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be7b624154cf30ec6a6a6a70a4435f13d66fa7234382811f54aa42a044575db9 |
|
MD5 | 59d270097e98fb2ce2baf86059e2aeee |
|
BLAKE2b-256 | 0ffca4c44604880747e9c36aca3c0e46226804f9ffbaf6c6014daadcad462f61 |
File details
Details for the file python_kv-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: python_kv-0.2.4-py3-none-any.whl
- Upload date:
- Size: 25.1 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 | 361f3b32dbb2f589e260c69258101c065f86dc9438398e8fa35c0bd253e79fe2 |
|
MD5 | b4d20775ad216b8e96a4dbcea790533f |
|
BLAKE2b-256 | ae3beb70603cd20dddd210278c4d8e251a6f3dc495284383807cb43773da2b8a |