Skip to main content

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


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.10.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

python_kv-0.2.10-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file python_kv-0.2.10.tar.gz.

File metadata

  • Download URL: python_kv-0.2.10.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for python_kv-0.2.10.tar.gz
Algorithm Hash digest
SHA256 b2a8936bee758590cbe5121ce5053b8e858e834c3fe011c6a483fa7c9621ab15
MD5 1ef278f5d00045a9a1ba79b38bfb9083
BLAKE2b-256 dd02cf4dacf8917d2e73a0a850b8dd9b5ca4b026d59c17a8b724ef362d519bcf

See more details on using hashes here.

File details

Details for the file python_kv-0.2.10-py3-none-any.whl.

File metadata

  • Download URL: python_kv-0.2.10-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

Hashes for python_kv-0.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 a4a94370fedc123788bb20c57cb1c221c0efad9cb5719a4fa933af6869541840
MD5 6dfb1c2d0282d543b2b80431f73e8a8e
BLAKE2b-256 b8a087392b83eeadf028879f58e26ee3c770695d5a9a335d990d5f19fd13a2fa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page