Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mgax/kv
Simple key-value store backed by sqlite
https://github.com/mgax/kv
Last synced: 8 days ago
JSON representation
Simple key-value store backed by sqlite
- Host: GitHub
- URL: https://github.com/mgax/kv
- Owner: mgax
- License: bsd-2-clause
- Created: 2012-10-02T23:43:03.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T20:32:14.000Z (almost 2 years ago)
- Last Synced: 2024-06-19T10:09:34.726Z (5 months ago)
- Language: Python
- Size: 23.4 KB
- Stars: 15
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: COPYING.txt
Awesome Lists containing this project
README
KV - simple key/value store
===========================.. image:: https://github.com/mgax/kv/actions/workflows/ci.yml/badge.svg?branch=master
KV provides a dictionary-like interface on top of SQLite. Keys can be
unicode strings, numbers or None. Values are stored as JSON.::
>>> from kv import KV
>>> db = KV('/tmp/demo.kv')
>>> db['hello'] = 'world'
>>> db[42] = ['answer', 2, {'ultimate': 'question'}]
>>> dict(db)
{42: [u'answer', 2, {u'ultimate': u'question'}], u'hello': u'world'}There is a locking facility that uses SQLite's transaction API::
>>> with kv.lock():
... l = db[42]
... l += ['or is it?']
... db[42] = lAnd that's about it. The code_ is really simple.
.. _code: https://github.com/mgax/kv