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.13.tar.gz
(3.7 kB
view details)
Built Distribution
File details
Details for the file kv_sqlite_sync-0.1.13.tar.gz
.
File metadata
- Download URL: kv_sqlite_sync-0.1.13.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b0bf1ee46f22675513f115065a5816982cd6eb1a5472f50a4f822097d3ff43a |
|
MD5 | e7f0b0a50df67615c7b575da8c613582 |
|
BLAKE2b-256 | 187ab0ceba7648fdb27cbb30a8e86ea51163744049d2b28f1b0da40b4692be9b |
File details
Details for the file kv_sqlite_sync-0.1.13-py3-none-any.whl
.
File metadata
- Download URL: kv_sqlite_sync-0.1.13-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47024b2570eb5b7cd01d2e970b9499af2d7a841511b64f260db896f5fde515cf |
|
MD5 | cf6102b44e929115f3a5c7a10f135f5c |
|
BLAKE2b-256 | 6e4377c5478b3df8a8c1104cd1feb342cbf4d54aa6b728097d5c49fed7423e7a |