TinyStore is another minuscule package I created for Django. It scratched an itch I had with a project I was working on at the time.
TinyStore allows you to keep named blobs of JSON data in a database, and read, update or delete them easily. A super-simple persistent key-value store, where the value can be any valid JSON object. It also allows you to define default values for these blobs in your settings.py
file.
Setting default values for TinyStore is completely optional, but for the purpose of this example I will start by defining two key-value pairs:
TINY_STORE = { "discount": {"enabled": False, "percentage": 12 }, "features": {"free_shipping": False } }
TinyStore.get("discount")
{"enabled": False, "percentage": 12 }
TinyStore.exists("discount")
True
TinyStore.keys()
["discount", "features"]
TinyStore.set("discount", {"enabled": True, "percentage": 8 })
TinyStore.get("discount")
{"enabled": True, "percentage": 8 }
TinyStore.remove("discount")
TinyStore.remove_all()
Note that keys with default values set are never removed entirely. Instead, they are just reset to their default values. This is by design: keys that you define defaults for must always exist.
Thanks for reading. You can find installation and usage docs in the GitHub repo. The package is available on PyPI. Happy coding!