libdb
Easy Management and Creation of Database Based on JSON Format with High Speed and Optimized.
Installation
Install With pip
in Windows:
pip install libdb
Install With pip3
in Linux:
sudo apt-get update&&sudo apt-get install python3-pip
pip3 install libdb
Install With Git
git clone https://github.com/libdb/libdb
cd libdb
Git Option's
Windows (python)
python install.py
python install.py upgrade
Linux (python3)
python3 install.py
python3 install.py upgrade
Usage
Here are some examples to demonstrate how to use the LibDB package.
Initializing the Database:
from libdb import JSONDatabase
db = JSONDatabase('mydb.json')
Creating a New Entry
db.create('name', 'Alice')
print(db.read('name'))
Bulk Creating Entries
items = {
'name': 'Alice',
'age': 30,
'city': 'Wonderland'
}
db.bulk_create(items)
print(db.read('age'))
print(db.read('city'))
Updating an Entry
db.update('name', 'Bob')
print(db.read('name'))
Deleting an Entry
db.delete('name')
print(db.read('name'))
Listing All Keys
list_keys = db.list_keys()
print(list_keys)
Clearing the Database
db.clear()
print(db.list_keys())
Searching for Entries
users = {
'user1': {'name': 'Alice', 'age': 30},
'user2': {'name': 'Bob', 'age': 25},
'user3': {'name': 'Charlie', 'age': 30}
}
db.bulk_create(users)
result = db.search('age', 30)
print(result)
Running Tests
You can run the tests to ensure everything is working correctly:
python -m unittest discover tests