Easy Management and Creation of Database Based on JSON Format with High Speed and Optimized.
pip install libdb
# if not installed pip3 sudo apt-get update&&sudo apt-get install python3-pip # Install With pip3 command pip3 install libdb
git clone https://github.com/libdb/libdb cd libdb
Windows (python)
# Install Libdb in windows python install.py # Just upgrade libdb in windows python install.py upgrade
Linux (python3)
# Install Libdb in Linux python3 install.py # Just upgrade libdb in Linux python3 install.py upgrade
Here are some examples to demonstrate how to use the LibDB package.
from libdb import JSONDatabase # Initialize the database db = JSONDatabase('mydb.json')
db.create('name', 'Alice') print(db.read('name')) # Output: Alice
items = { 'name': 'Alice', 'age': 30, 'city': 'Wonderland' } db.bulk_create(items) print(db.read('age')) # Output: 30 print(db.read('city')) # Output: Wonderland
db.update('name', 'Bob') print(db.read('name')) # Output: Bob
db.delete('name') print(db.read('name')) # Output: None
list_keys = db.list_keys() print(list_keys) # Output: ['age', 'city']
db.clear() print(db.list_keys()) # Output: []
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) # Output: {'user1': {'name': 'Alice', 'age': 30}, 'user3': {'name': 'Charlie', 'age': 30}}
You can run the tests to ensure everything is working correctly:
python -m unittest discover tests