Skip to content

Fl1yd/LightDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


LightDB: Lightweight JSON Database for Python

What is this?

LightDB is a simple and lightweight JSON database for Python that allows users to efficiently write data to a file. It is designed to be easy to use, making it a great choice for developers who need a fast and reliable way to store and retrieve data.

Installing

You can install LightDB using pip:

pip install lightdb

Usage

To use LightDB, first import the LightDB class from the lightdb package:

from lightdb import LightDB

Then, create a LightDB object by passing in the path to a JSON file where the database will be stored:

db = LightDB("my_database.json")

You can then set key-value pairs in the database using the set() method:

db.set("name", "Alice")
db.set("age", 30)

You can get the value associated with a key using the get() method:

name = db.get("name")
age = db.get("age")

You can also remove a key-value pair using the pop() method:

db.pop("age")

To reset the database to an empty state, use the reset() method:

db.reset()

After making the changes, you need to save():

db.save()

License

LightDB is licensed under the MIT License.