Skip to main content

Key-Value interface over SQLite. Supports any datatype, including JSON and BLOB

Project description

Sqlite Kv (Sync)

Implementation of the KV[T]async Key-Value ABC, over python's sqlite3

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


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

Uploaded Source

Built Distribution

kv_sqlite_sync-0.1.11-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file kv_sqlite_sync-0.1.11.tar.gz.

File metadata

  • Download URL: kv_sqlite_sync-0.1.11.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

Hashes for kv_sqlite_sync-0.1.11.tar.gz
Algorithm Hash digest
SHA256 73df341976d6bde106c7662c703d1d8c376f8c09a879cadfa4b83ccbac7d4572
MD5 676f05f52c764b3433aa3663b900c694
BLAKE2b-256 5153ffecb8a17b05c895bec36a0d35cdb64a8a5967645c73be5a8f0401492cea

See more details on using hashes here.

File details

Details for the file kv_sqlite_sync-0.1.11-py3-none-any.whl.

File metadata

File hashes

Hashes for kv_sqlite_sync-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 9ccef3c52ea3d606173966159395a76d79819ec2ee246347a75c09d73b36c288
MD5 56b71341a896130f3fc9db5b886ee224
BLAKE2b-256 1e149234e32cb263f07fc0080bb2a7fb45697e269f0cc879fe94338b4fcde175

See more details on using hashes here.

Supported by

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