Simple File-based KV-Store
Project description
# kvfile
[![Travis](https://img.shields.io/travis/akariv/kvfile/master.svg)](https://travis-ci.org/akariv/kvfile)
[![Coveralls](http://img.shields.io/coveralls/akariv/kvfile.svg?branch=master)](https://coveralls.io/r/akariv/kvfile?branch=master)
A simple Key-Value store that's file based - so can accommodate large data sets with a small memory footprint.
Internally will use the faster `leveldb` as a storage backend or `sqlite3` as fallback if `leveldb` is not available.
## The Basics
The API should feel familiar to anyone working with Python.
It exposes `get`, `keys` and `items` for reading from the DB, and `set` for setting a value in the DB.
```python
import datetime
import decimal
from kvfile import KVFile
kv = KVFile()
kv.set('s', 'value')
kv.set('i', 123)
kv.set('d', datetime.datetime.fromtimestamp(12325))
kv.set('n', decimal.Decimal('1234.56'))
kv.set('ss', set(range(10)))
kv.set('o', dict(d=decimal.Decimal('1234.58'),
n=datetime.datetime.fromtimestamp(12325)))
assert kv.get('s') == 'value'
assert kv.get('i') == 123
assert kv.get('d') == datetime.datetime.fromtimestamp(12325)
assert kv.get('n') == decimal.Decimal('1234.56')
assert kv.get('ss') == set(range(10))
assert kv.get('o') == dict(d=decimal.Decimal('1234.58'),
n=datetime.datetime.fromtimestamp(12325))
assert sorted(kv.keys()) == ['d', 'i', 'n', 'o', 's', 'ss']
assert sorted(kv.items()) == [
('d', datetime.datetime.fromtimestamp(12325)),
('i', 123),
('n', decimal.Decimal('1234.56')),
('o', {'d': decimal.Decimal('1234.58'),
'n': datetime.datetime.fromtimestamp(12325)}),
('s', 'value'),
('ss', {0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
]
```
## Installing leveldb
On Debian based Linux:
```bash
$ apt-get install libleveldb-dev libleveldb1
```
On Alpine based Linux:
```bash
$ apk --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --update add leveldb leveldb-dev
```
On OS X:
```bash
$ brew install leveldb
```
[![Travis](https://img.shields.io/travis/akariv/kvfile/master.svg)](https://travis-ci.org/akariv/kvfile)
[![Coveralls](http://img.shields.io/coveralls/akariv/kvfile.svg?branch=master)](https://coveralls.io/r/akariv/kvfile?branch=master)
A simple Key-Value store that's file based - so can accommodate large data sets with a small memory footprint.
Internally will use the faster `leveldb` as a storage backend or `sqlite3` as fallback if `leveldb` is not available.
## The Basics
The API should feel familiar to anyone working with Python.
It exposes `get`, `keys` and `items` for reading from the DB, and `set` for setting a value in the DB.
```python
import datetime
import decimal
from kvfile import KVFile
kv = KVFile()
kv.set('s', 'value')
kv.set('i', 123)
kv.set('d', datetime.datetime.fromtimestamp(12325))
kv.set('n', decimal.Decimal('1234.56'))
kv.set('ss', set(range(10)))
kv.set('o', dict(d=decimal.Decimal('1234.58'),
n=datetime.datetime.fromtimestamp(12325)))
assert kv.get('s') == 'value'
assert kv.get('i') == 123
assert kv.get('d') == datetime.datetime.fromtimestamp(12325)
assert kv.get('n') == decimal.Decimal('1234.56')
assert kv.get('ss') == set(range(10))
assert kv.get('o') == dict(d=decimal.Decimal('1234.58'),
n=datetime.datetime.fromtimestamp(12325))
assert sorted(kv.keys()) == ['d', 'i', 'n', 'o', 's', 'ss']
assert sorted(kv.items()) == [
('d', datetime.datetime.fromtimestamp(12325)),
('i', 123),
('n', decimal.Decimal('1234.56')),
('o', {'d': decimal.Decimal('1234.58'),
'n': datetime.datetime.fromtimestamp(12325)}),
('s', 'value'),
('ss', {0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
]
```
## Installing leveldb
On Debian based Linux:
```bash
$ apt-get install libleveldb-dev libleveldb1
```
On Alpine based Linux:
```bash
$ apk --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --update add leveldb leveldb-dev
```
On OS X:
```bash
$ brew install leveldb
```
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
kvfile-0.0.1.tar.gz
(6.1 kB
view hashes)
Built Distribution
Close
Hashes for kvfile-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a5570611fd0cfa472062461965c978ba5e792cbe07137e7d5a77478235ce971 |
|
MD5 | 9214787a94d80c9fc8b3dc586260ba58 |
|
BLAKE2b-256 | a097109f50daaa9f77b0a1930270fdc9eb5dbcf9d32bd0b6e9821b0c1a8a0ba9 |