Key-Value interface over SQLite. Supports any datatype, including JSON and BLOB
Project description
Key-Value: SQLite3
Implementation of the
KV[T]
async Key-Value ABC, over python'ssqlite3
pip install kv-sqlite-sync
Usage
Custom serialization
from kv.sqlite import SQLiteKV, InvalidData
from haskellian import Either, Left, Right
import json
def safe_parse(x: str) -> Either[InvalidData, dict]:
try:
return Right(json.loads(x))
except Exception as e:
return Left(InvalidData(e))
kv = SQLiteKV[dict].at(
db_path='mydb.sqlite', table='my-jsons',
dtype='JSON', parse=json.loads, dump=json.dumps
)
await kv.insert('key1', {'a': 1, 'b': 2})
Pydantic-validated types
from kv.sqlite import SQLiteKV
kv = SQLiteKV.validated(
tuple[str, int],
db_path='mydb.sqlite', table='my-tuples',
)
await kv.insert('key1', ('a', 1))
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
kv_sqlite_sync-0.1.12.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for kv_sqlite_sync-0.1.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 588e5fc8bf4c20dbbdb68b0d3858a6bd5a772e8c847541dabbaa52a23f6b7874 |
|
MD5 | 8cb7cc04e0ce31964911ebdddf69093d |
|
BLAKE2b-256 | 3aaaf61d2a2e6872109ad7fde8c163b45ae363a027a168fd2223a4035b81526d |