/pyjsonlog

a log store for JSON datastructures

Primary LanguagePythonMIT LicenseMIT

Abstract

A python package implementing a filesystem based store of JSON datastructures, where older versions are never deleted.

Travis-CI says https://travis-ci.org/uucidl/pyjsonlog.svg?branch=master

Why should I use json-log-store?

When developing a python-based application or command line tool, you can use this file store to store your data.

Iterating on the solution or creating composite solutions made of multiple tools can then be done with the confidence you will not lose any data.

Application area

  • Python applications
  • Data can be serialized as JSON
  • Mostly reads, few writes

Using

import os
from jsonlog import DataStore, DataStoreFS

root_dir = "<somewhere on your filesystem>"
os.makedirs(root_dir)
ds = DataStore(DataStoreFS(root_dir))

# put first version in the store
os.makedirs(os.path.join(root_dir, 'my-item'))
ds.put('item', 'my-item', dict(version=0))

# read and update the item
item = ds.get('my-item')
item['info'] = 'Hello, World'
ds.put('item', 'my-item', item)

Then you should be able to see in <root_dir>/my-item/:

item-1.json
item-2.json

Contributing

Here are the steps to follow to get a working development environment:

Create a virtual environment and activate it

$ virtualenv venv
$ . venv/bin/activate

Install development dependencies

$ pip install -r requirements.txt dev_requirements.txt

With the virtual environment active, test your changes before submitting:

$ nosetests -s tests

License

see LICENSE