Searchable, persistent Python dict database backed by JSON files — for those times when SQL is overkill.
pip install json_databaseEncryption features additionally require pycryptodomex:
pip install json_database pycryptodomexfrom json_database import JsonStorage, JsonDatabase
from json_database.search import Query
# Persistent dict
with JsonStorage("/tmp/config.json") as cfg:
cfg["host"] = "localhost"
cfg["port"] = 5432
# auto-saved on exit
# Searchable list-of-records
with JsonDatabase("users", "/tmp/users.jsondb") as db:
db.add_item({"name": "Alice", "role": "admin"})
db.add_item({"name": "Bob", "role": "user"})
admins = db.search_by_value("role", "admin")
# Fluent query builder
results = Query(db).equal("role", "user").build()- Pure Python, minimal dependencies (
combo_lockonly) - Persistent dict (
JsonStorage) and list-of-records database (JsonDatabase) - Recursive search by key and key/value pair, with optional fuzzy matching
- Fluent
Querybuilder for multi-condition filtering - AES-256-GCM encryption at rest (
EncryptedJsonStorage) - XDG Base Directory compliant variants for Linux applications
- File locking via
combo_lockfor safe concurrent access - Supports commented JSON files (
//and#line comments) - Arbitrary Python objects stored via automatic
jsonify_recursivelyconversion - HiveMind plugin (
hivemind-json-db-plugin) for voice assistant integration
| Class | Default path | Use for |
|---|---|---|
JsonStorage(path) |
user-specified | any persistent dict |
JsonStorageXDG(name) |
~/.cache/json_database/{name}.json |
cache / temp data |
JsonConfigXDG(name) |
~/.config/json_database/{name}.json |
app settings |
JsonDatabaseXDG(name) |
~/.local/share/json_database/{name}.jsondb |
persistent records |
EncryptedJsonStorage(key, path) |
user-specified | sensitive data at rest |
Note: Item IDs in
JsonDatabaseare stable list indices.add_itemandappendreturn the zero-based slot index of the new item. Removing an item tombstones its slot rather than shifting subsequent IDs, so an ID obtained fromadd_itemorget_item_idremains valid for the lifetime of the database file. Tombstoned slots are invisible to iteration, search,__contains__, and__len__; accessing one viadb[item_id]raisesInvalidItemID.
Warning: Encryption keys longer than 16 bytes are silently truncated to 16 bytes. Always use exactly 16 bytes.
- Installation — dependencies, Python version support
- Quick Start — 5-minute walkthrough with examples
- API Reference — all public classes and methods
- Encryption — AES-GCM details, key rules, security notes
- XDG Paths — XDG spec support and path resolution
- Search and Query — all filter methods, fuzzy matching
- Development — running tests, CI, contributing
- Architecture — class hierarchy, data flow, design
This project includes a native hivemind-plugin-manager
integration, providing JSON-backed storage for HiveMind client credentials and
permissions via the hivemind-json-db-plugin entry point.
MIT