Boss-1s/key_multivalue_storage · 文件
文件最后提交记录最后更新时间
README.md
Key to Multivalue Storage - kms
kms - a tiny side project tuned into a library.
JSON storage wrapper and editor. Created with love by Boss_1s.
Once upon a time, this was just a small project to solve a problem: the over-steep learning curve for scratchattach's database functionality. Now, I have decided to make it a library, something with humble beginnings with big hopes in its future.
This is, after all, the greatest piece of a CPython progam I have made. ;)
Badges
Download
Status
Info & Docs
Installation
Install with pip:
pip install -U key-multivalue-storage
Or, download the latest version of the .whl file in the releases page
You can also choose to download the development environment alongside the package:
pip install -U key-multivalue-storage[dev]
The development package includes Pylint and Griffe for testing and finding breaking changes. You can see the tests in the test folder.
Usage
- Create a Storage object to wrap the data to be stored:
from key_multivalue_storage import Storage
my_db = Storage("my_top_level_key", mysubkey="myvalue", myothersk="anotherval")
- To store the object, use
Storage.store().
my_db.store("database.json")
- You can change certain global variables for each
Storageinstance.
Storage.indent = 4 # indent size of JSON files
Storage.encode = True # Whether to encode stored values
Storage.auto_delete_self = True
# Whether to automatically release the object
# from memory after certain operations i.e.
# Storage.store()