Skip to main content

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: kv_sqlite_sync-0.1.12.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.12.tar.gz
Algorithm Hash digest
SHA256 d84fc9e4f514651134b48f34094cbb6ff2f1700a01dc6e767e1ffb154a630bc5
MD5 264c8adb12d6a9b363e7b6a865a56f48
BLAKE2b-256 7e7680e1b1acd4010e67989676cdc80ccc210c241258e5539df426c8fe0be2df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kv_sqlite_sync-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 588e5fc8bf4c20dbbdb68b0d3858a6bd5a772e8c847541dabbaa52a23f6b7874
MD5 8cb7cc04e0ce31964911ebdddf69093d
BLAKE2b-256 3aaaf61d2a2e6872109ad7fde8c163b45ae363a027a168fd2223a4035b81526d

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