PysonDB
- Install
- Example Code
- Command Line Operations
- Adding Data
- Get data
- Search data
- Update Data
- Delete Data
Add Data
- Adding data is is simple.
- There are two methods to add data.
- add()
- addMany()
- The Schemma of data you add first is the schemma for the whole database.
- Adding data checks for Schemma regularity.
- And any Schemma irregularity rejects the irregular data.
add()
-
add({βkeyβ:βvalue,βkeyβ:value})
-
add(json)
>> from pysondb import db
>> #from pysondb import getDb
>> #a=getDb("test.json")
>> a=db.getDb("pathtojson.json")
>> a.add({"name":"pysondb","type":"DB"})
>> # returns 1929323232 which is a ID assigned to the above data.
>> a.add({"namme":"pyson","type":"DB"})
>> # The data wont be added as the key "name" is mispelled as "namme"
addMany()
-
addMany([{},{},β¦])
-
addMany(list of dictionaries)
>> from pysondb import db
>> a=db.getDb("pathtojson.json")
>> a.addMany([{"name":"pysondb","type":"DB"},{"name":"py_cli","type":"CLI"}])
>> # Both data is added in the database.
>> a.add([{"namme":"pyson","type":"DB"},{"name":"py_cli2","type":"CLI"}])
The first data wont be added as the key "name" is mispelled as "namme"
But the second data will be added.
>>a.getAll()
{"name":"pysondb","type":"DB"},{"name":"py_cli","type":"CLI"},{"name":"py_cli2","type":"CLI"}]