Skip to main content

Easy Management and Creation of Database Based on JSON Format with High Speed and Optimized

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libdb-1.0.6.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

libdb-1.0.6-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file libdb-1.0.6.tar.gz.

File metadata

  • Download URL: libdb-1.0.6.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for libdb-1.0.6.tar.gz
Algorithm Hash digest
SHA256 c2e9b93ad50891a9560ad4d630bce79634c22b8289b0fb804ee4e4db16855046
MD5 4102d683a465c3dbe78851a75502f311
BLAKE2b-256 bd9079e4e920be81fe3ced29c8622e084c843286af7464db155225c70ecb86fc

See more details on using hashes here.

File details

Details for the file libdb-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: libdb-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for libdb-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d3c495c0d74aaf37b66bd327b89886ba32170b94f24e52905aed999ccb91c151
MD5 20ccf438633f524427b152e8f244c180
BLAKE2b-256 2e4c5b9fabba09d0200eefa5f2aa28523c46a3b10ab5d14dd45c0691187b79a9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page