Skip to content

Jdbase-client Documentation

Overview

jdbase-client is a Python library designed to provide a convenient interface for interacting with JDBase remote database via an HTTP API. It simplifies common database operations such as creating, reading, updating, and deleting records, as well as performing custom queries. This library assumes that a compatible server is running and accessible at the provided API endpoint.

Installation

You can install jdbase-client via pip:

pip install jdbase-client

Usage

To use jdbase-client, you need to instantiate a Database object with the necessary configuration. This configuration includes the API key, API endpoint, and the name of the database. Once instantiated, you can use this object to perform various database operations.

Example

from jdbase_client import Database

# Configuration settings
config = {
    'api_key': 'adminkey',
    'api_endpoint': 'http://127.0.0.1:5000/api',
    'db': 'db2'
}

# Instantiate the Database object
db = Database(config)

# Example usage: Matching records
matching_records = db.match({"id": 2, "age": 30})
print(matching_records)

Class: Database

Methods

create(query: dict) -> dict

Creates a new record in the database.

  • query: A dictionary representing the data to be inserted.

Example:

db.create({
    "name":"Rakib Hossain",
    "age":22,"skill":"python"
    })

Returns:
A dictionary containing the result of the operation.

get_by(query: dict) -> dict

Retrieves records from the database based on the provided query.

  • query: A dictionary representing the query parameters. Example:

    db.get_by({"id: 5})

Returns:
A dictionary containing the retrieved records.

update(query: dict, update_query: dict) -> dict

Updates records in the database based on the provided query and update query.

  • query: A dictionary representing the query to identify records to be updated.
  • update_query: A dictionary representing the update operation to be performed on matching records.

Example:

db.update({
    "Skill": "Python"
},
{
    "Skill":"Python_Api"
})

Returns:
A dictionary containing the result of the operation.

delete(query: dict) -> dict

Deletes records from the database based on the provided query.

  • query: A dictionary representing the query to identify records to be deleted.

Example:

db.delete({"skill":"PHP"})

Returns:
A dictionary containing the result of the operation.

match(query: dict) -> dict

Performs a custom matching query on the database.

  • query: A dictionary representing the matching criteria.

Example:

db.match({"email":"user@jdmail.com",
    "password":"user@password"})

Returns:
A dictionary containing the matching records.

create_db(query: dict) -> dict

Creating New Database.

  • query: A dictionary representing Name of Database

Example:

db.create_db({"name":"users"})

Returns:
A dictionary containing the matching records.

Conclusion

jdbase-client simplifies database interactions by providing an easy-to-use interface for common operations. By following the provided documentation, you can seamlessly integrate this library into your Python projects and interact with your JDBase remote database.

Checkout JDBase Here