Giter Club home page Giter Club logo

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:

# if not installed pip3
sudo apt-get update&&sudo apt-get install python3-pip 
# Install With pip3 command
pip3 install libdb

Install With Git

git clone https://github.com/libdb/libdb
cd libdb

Git Option's

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

Usage

Here are some examples to demonstrate how to use the LibDB package.

Initializing the Database:

from libdb import JSONDatabase
# Initialize the database
db = JSONDatabase('mydb.json')

Creating a New Entry

db.create('name', 'Alice')
print(db.read('name'))  # Output: Alice

Bulk Creating Entries

items = {
    'name': 'Alice',
    'age': 30,
    'city': 'Wonderland'
}
db.bulk_create(items)
print(db.read('age'))  # Output: 30
print(db.read('city'))  # Output: Wonderland

Updating an Entry

db.update('name', 'Bob')
print(db.read('name'))  # Output: Bob

Deleting an Entry

db.delete('name')
print(db.read('name'))  # Output: None

Listing All Keys

list_keys = db.list_keys()
print(list_keys)  # Output: ['age', 'city']

Clearing the Database

db.clear()
print(db.list_keys())  # Output: []

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)  # Output: {'user1': {'name': 'Alice', 'age': 30}, 'user3': {'name': 'Charlie', 'age': 30}}

Running Tests

You can run the tests to ensure everything is working correctly:

python -m unittest discover tests

libdb's Projects

libdb icon libdb

Python Database Management Json File Very Fast and Easy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.