pysonDB

A Simple , ☁️ Lightweight , 💪 Efficent JSON based database for 🐍 Python. PysonDB-V2 has been released ⬇️

View on GitHub

PysonDB

Update Data

JSON file:file.json

{"data": [{"name": "PysonDB", "type": "DB", "score": "10", "id": 5161221802},
{"name": "Pyson-CLI", "type": "CLI", "score": "10", "id": 2242313690},
{"name": "Tiny", "type": "DB", "score": "9", "id": 6991190264},
{"name": "QWERTY", "type": "DB", "score": "5", "id": 9416036202}]}

updateById(ID,what_to_update)

>> from pysondb import db
>> a=db.getDb("file.json")
>> a.updateById("9416036202",{"name":"Qwerty12"})
>> a.getBy({"name":"Qwerty12"})
>> #In the file.json the data is updated.
>> #We can verify it below.
>> [{"name": "Qwerty12", "type": "DB", "score": "5", "id": 9416036202}]

update(query,what_to_update)

>> from pysondb import db
>> a=db.getDb("file.json")
>> a.update({"name":"Pyson-CLI"},{"name":"PysonCLI"})
>> a.getBy({"name":"PysonCLI"})
>> # In the file.json the data is updated for all data where name=Pyson-CLI
>> # We can verify it below.
>> [{"name": "PysonCLI", "type": "CLI", "score": "10", "id": 2242313690}]


updateArray(query, prop_to_update, value_to_append, max_array_capacity=float('inf'))

>> from pysondb import db
>> a=db.getDb("file.json")
>> a.getBy({"name":"ArrayEntry"})
>> [{"name":"ArrayEntry", "epic_array":[0,1,2]}]
>> a.updateArray({"name":"ArrayEntry"},"epic_array",3)
>> a.getBy({"name":"ArrayEntry"})
>> # In the file.json the data is updated for all data where name=Pyson-CLI
>> # We can verify it below.
>> [{"name": "ArrayEntry", "epic_array":[0,1,2,3]}]
>> a.updateArray({"name":"ArrayEntry"}, "epic_array", 4, 4)
>> a.getBy({"name":"ArrayEntry"})
>> [{"name": "ArrayEntry", "epic_array":[1,2,3,4]}