Skip to content
Flat-file JSON store designed for concurrent write access
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



I like using with because I am lazy and the interface is convenient. I really like the simplicity, but I also want some concurrency.

When I need to write concurrently, I have reached for MongoDB because it scales well. However, I need to install and run the MongoDB server which can be a burden for some people.

What If?

What if we just stored JSON documents on the filesystem using a simple file locking mechanism to allow for concurrent access? Interested? Then it is time to become a grocer and open your own store.

Opening your own store

Import grocer:

from grocer import grocer

Initialize a Store:

store = grocer.Store("./store")

The Store is initialized with the path ./store on your filesystem which may or may not exist. You access your Store, similarly to a dictionary, via an Aisle. An Aisle is analogous to a collection or table in other databases. Example:

aisle = store["produce"]

This will access the Aisle ./store/produce which will contain JSON objects called SKUs. SKU stands for stockkeeping unit and must be unique. An example:

aisle.stock_one({"sku": "eggplant", "price": 3.50})

The above command will create the file ./store/produce/eggplant.json with the following JSON inside:

{"price": 3.5}



Be as simple as possible. Lock SKUs for concurrent writes.

You can’t perform that action at this time.