Skip to content

NaiveDB - Database for the naive by the naive :)

Notifications You must be signed in to change notification settings

rajat-008/naivedb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

naivedb

NaiveDB is a easy to use all Python database, inspired by the TinyDB project and File Structures university course.

Future enhancements

  • Clean the code
  • Write tests and achieve test 100% coverage
  • Allow updates to database structure in a declarative manner( inspired by Django models and GCP Cloud Deployment Manager)
  • Develop a simple CLI to interact with NaiveDB. As of now the only way to interact is through Python code.
  • Allow addition and updation of Tables after DB creation.

Decision log

  • The format in which the table data is accepted is considering the ease to migrate to a delcarative format(and although it may seem verbose now, the declarative format will make the decision worth it).

Getting started - Creating and using sample DB

Creating Database

from naivedb import NaiveDB

user={
    "name":"user",
    "fields":[
            "name",
            "id",
            "email"
    ],
    "primary_key":"email"
}

courses={
    "name":"courses",
    "fields":[
            "name",
            "id",
            "domain",
            "instructor"
    ],
    "primary_key":"id"
}

tables=[user, courses]

#create DB
NaiveDB.create_db(name = "my_db", loc = "/home/rajat/college", tables = tables)

Instantiating DB and perform queries

#instantiate DB
db = NaiveDB(db_loc = "/home/rajat/college")

#insert in Table "user"
user1={"name":"user1","id":"2020", "email":"[email protected]"}
db.user.insert(user1)

#query the DB
db.user.search("[email protected]")
#output : {'name': 'user1', 'id': '2020', 'email': '[email protected]'}

res = db.user.search("[email protected]")
#output : False

About

NaiveDB - Database for the naive by the naive :)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages