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. ;)
Install with pip:
pip install -U key-multivalue-storageOr, 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.
- 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")
Data stored successfully in '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- Load the data back into a Storage object:
>>> import key_multivalue_storage as kms
>>> loaded_db = kms.Load.by_key("database.json", "my_top_level_key") # You can also use Storage.Load.by_key()
>>> loaded_db = my_db
True- You can also cast a Storage object into a dictionary!
>>> dict_db = dict(my_db)
>>> dict_db
{"my_top_level_key":{"mysubkey":"myvalue","myothersk":"anotherval"}}There's a lot more to this library that what meets the eye.
See the full documentation here!
Have a GREAT day/night! :)