NotDB PYON-like database


Keywords
notdb, db, database, notdatabsae, simple
License
MIT
Install
pip install notdb==1.2.6

Documentation

NotDB is now updated as SpeedDB


old docs:

Logo Transparnet

NotDB

NotDB is an open source document-oriented database that uses PYON-like documents

Twitter PayPal Discord

Table of Contents

Installation

PIP

pip install notdb

Quick Start

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

How To Use

DB Info

db.documents # will return number of documents in the database
db.host # will return db host (path)

get, getOne

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

appendOne, appendMany

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

removeOne, removeMany

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

updateOne, updateMany

NotDB have 2 types of updates SET and UNSET

I will add more in the future😅

How to acccess update types

import notdb

dir(notdb.UTypes) # ['SET', 'UNSET', ...]

SET

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)

UNSET

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}

POP

# 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

View Your Data

Best way to see your db data is by using notdb_viewer

NotDB Viewer Image