Skip to content

cloudmesh/yamldb

Repository files navigation

YamlDB

GitHub Repo image image License

General badge GitHub issues Contributors General badge

Linux macOS Windows

YamlDB is an easy to use file-based database using YAML as the format for the data represented in the file. This makes it possible to quickly change and add values in the file itself while it can then be loaded and used as a dict in your application.

It has the ability to use a dot notations for the keys instead of nested brackets. It also creates parents if they do not exist.

Note: you must be using python 3.8 or newer

pip install yamldb

from yamldb import YamlDB

db = YamlDB(filename="data.yml")

db["a"] = "1"
db["b.c"] = "2"

d = db.get("a.b.c.d", default=3)

db.load()
  reloads the file
  
db.delete("b.c")
    deletes the key b.c
    to save the state you have to also call db.save()
    
db.save()
  saves the current db into the file

db.search("a.*.c")
   quries the db
   see: https://jmespath.org/tutorial.html
   

Development and tests

The best way to contribute is with issues and pull requests. You will need to check out the development version such as

git clone https://github.com/cloudmesh/yamldb.git
cd yamldb
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -e .

Then you can run the a test with

pytest -v --capture=no tests/test_config.py

Alternatives

Acknowledgments

Continued work was in part funded by the NSF CyberTraining: CIC: CyberTraining for Students and Technologies from Generation Z with the award numbers 1829704 and 2200409.