NotDB is now updated as SpeedDB
NotDB is an open source document-oriented database that uses PYON-like documents
pip install notdb
First create your db file
notdb [dbname]
if you want to secure your db with a password you can use the --password
or -p
flag
notdb [dbname] --password
it will ask you for the password
import notdb
db = notdb.NotDBClient('[dbname]') # replace [dbname] with your database name
db.get({}) # will return every document
db.documents # will return number of documents in the database
db.host # will return db host (path)
db.get({'admin': True}) # will return a list of documents that match the filter
db.getOne({'admin': True}) # will return the "first" element that match the filter
db.appendMany([{'name': 'Nawaf'} for i in range(10)])
# this will append "{'name': 'Nawaf'}" to the database 10 times
db.appendOne({'name': 'Nawaf'})
# this will append "{'name': 'Nawaf'}" to the database 1 time
db.appendMany([{'name': 'Nawaf'} for i in range(10)])
# appending "{'name': 'Nawaf'}" 10 times
db.removeOne({'name': 'Nawaf'})
# this will just remove the first "{'name': 'Nawaf'}"
print(db.documents) # 9
db.appendMany([{'name': 'Nawaf'} for i in range(10)])
# appending "{'name': 'Nawaf'}" 10 times
db.removeMany({'name': 'Nawaf'})
# This will remove every "{'name': 'Nawaf'}" in the database
db.removeMany({})
# This will remove every thing from the database
NotDB have 2 types of updates SET
and UNSET
I will add more in the future😅
import notdb
dir(notdb.UTypes) # ['SET', 'UNSET', ...]
db.appendOne({'name': 'Nawaf'})
# adding "{'name': 'Nawaf'}" to the db
# first parameter is "_filter" -> which document you are trying to edit
# second parameter is "update" -> what key you are trying to SET/UNSET
# last parameter is "type" -> update type: SET or UNSET
db.updateOne({'name': 'Nawaf'}, {
'age': 15
}, notdb.UTypes.SET)
# Easy, right?
db.updateOne({'name': 'Nawaf'}, {
'programmingLangs': ['Python', 'JavaScript', 'C++']
}, notdb.UTypes.SET)
db.appendOne({'name': 'Nawaf', 'age': 15})
# adding "{'name': 'Nawaf'}" to the db
db.updateOne({'name': 'Nawaf'}, 'age', notdb.UTypes.UNSET)
# Since we are unsetting a key we don't need its value
# That's why we specified "age" for the update not {'age': 15}
# let's say this is our document
# {'name': 'Nawaf', 'skills': {'languages': ['Python', 'JavaScript', 'C']}}
db.updateOnePOP({'name': 'Nawaf'}, 'skills.languages', -1)
# -1 will remove the last element
Best way to see your db data is by using notdb_viewer