PysonDB
- Install
- Example Code
- Command Line Operations
- Adding Data
- Get data
- Search data
- Update Data
- Delete Data
Get Data
- There are three methods to get data.
- get(n, objectify=False)
- getAll(objectify=False)
- getBy(query, objectify=False)
- find(id)
get()
-
returns only one data by default.
-
get(3) => retruns 3 json data.
path.json
{"data":[{"name":"pysondb","type":"DB"},{"name":"py_cli","type":"CLI"},{"name":"py_cli2","type":"CLI"}]}
>> from pysondb import db
>> a=db.getDb("path.json")
>> a.get()
>> [{"name":"pysondb","type":"DB"}]
>> a.get(1)
>> [{"name":"pysondb","type":"DB"},{"name":"py_cli","type":"CLI"}]
getAll()
- Returns all data in the database
>> from pysondb import db
>> a=db.getDb("path.json")
>> a.getAll()
>> [{"name":"pysondb","type":"DB"},{"name":"py_cli","type":"CLI"},{"name":"py_cli2","type":"CLI"}]
getBy(query)
- getBy(query) query must be a JSON data.
- getBy({βtypeβ:βCLIβ})
>> from pysondb import db
>> a=db.getDb("path.json")
>> a.getBy({"type":"CLI"})
>> [{"name":"py_cli","type":"CLI"},{"name":"py_cli2","type":"CLI"}]
>> a.getBy({"name":"py_cli"})
>> [{"name":"py_cli","type":"CLI"}]
find(id)
- find(id) : Id must be a Int.
- find(23234234345345345)
>> from pysondb import db
>> a=db.getDb("path.json")
>> a.getAll()
>> [{"name":"pysondb","type":"DB",id:1234},{"name":"py_cli","type":"CLI",id:5678},{"name":"py_cli2","type":"CLI",id:9101112}]
>> a.find(1234)
>> {"name":"pysondb","type":"DB",id:1234}