Skip to content

MahmoudGoda2003/SimpleFSDB

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple file system database (DataHive)

PyPI Downloads PyPI

Overview

DataHive is a meticulously crafted, lightweight database system tailored for the purpose of data storage in JSON files. With a strong emphasis on simplicity and reliability, it offers essential CRUD (Create, Read, Update, Delete) operations and guarantees seamless synchronization between read and write operations. This project has been thoughtfully designed to serve as an elegant and file-based data storage solution, ideally suited for small-scale applications.

Table of Contents

  1. Features
  2. Installation
  3. Usage
  4. Example Usage
  5. FAQs
  6. Contributing
  7. License
  8. Upcoming Features

1. Features

  • Data Storage Excellence

    • Robust Storage: Securely store data in JSON format.
    • Flexibility: JSON supports diverse data types and complex structures.
    • Transparency: Human-readable format simplifies debugging.
    • Compatibility: Platform-independent for use in various applications.
  • CRUD Functionality

    • Create (C): Add new data with specified identifiers.
    • Read (R): Retrieve and query data for targeted searches.
    • Update (U): Modify existing data, ensuring accuracy.
    • Delete (D): Remove data to maintain a clean database.
  • Synchronization Assurance

    • ead-Write Consistency: Guarantee synchronization between read and write operations for up-to-date data.
    • Data Integrity: Maintain reliable and trustworthy data, preventing inconsistencies.
  • Clearing Database:

    • clear the data: Wipe the database clean, starting fresh for new data.
  • Java Integration

    • Cross-Language Compatibility: Our meticulously crafted Java driver (SimpleDBDriver) seamlessly integrates with the Simple File System Database, allowing Java applications to interact with the database effortlessly. This cross-language compatibility enhances the database's versatility, extending its usability to diverse programming ecosystems.

2. Installation

To use DataHive, follow these installation steps:

  1. Install python: Python 3.x installed on your machine.

  2. Install DataHive: Install DataHive package on your local machine:

pip install DataHive

3. Usage

Schema Format

Below is an example of the schema format that defines the structure of the database, including the database name and tables with their respective attributes:

  1. Schema Example:

    {
        "database_name" : "ClassA1",
        "Tables" : [
            {
                "name" : "student",
                "columns" : ["First_name", "Last_name", "CGPA", "Gender", "Age"],
                "primary_key"  : "Last_name",
                "index_keys" : ["First_name", "Last_name", "CGPA"],
                "overwrite" : "True",
           }
                    ]
     }
    
  2. Table Contents: The schema format consists of the following elements for defining tables within the database:

    Name Type Nullable Notes
    Name string No Name of the table.
    Columns List of Strings No List of column names, including the primary key.
    Primary_key String No The primary key for the table.
    Index_key List of Strings Yes List of column names that serve as index keys.
    Overwrite string Yes Initial value is 'False'; you can set its value to 'True' to enable overwriting.

Command-Line Interface

Note: Ensure that you have a JSON file containing your schema before creating the database.

Command Parameters Description
Create DatabaseSchemaPath Creates a database following the specified schema.
Set DatabaseName, TableName, InputData Sets a row with the provided input data.
Get DatabaseName, TableName, InputQuery Utilizes the input query to retrieve specific data from the database.
Delete DatabaseName, TableName, InputQuery Uses the input query to delete specific data from the database.
Clear DatabaseName Resets the specified database to its initial state.

This Command-Line Interface (CLI) provides a set of commands for creating, updating, querying, deleting data, and resetting databases, offering comprehensive control over your data management tasks.

4. Example Usage

  • The general format for any command in the program is as follows:

    python DataHive -c [command] [options]

    Replace [command] with the desired database command and [options] with relevant command options.

  • Commands Examples:

    • Creating a new database:

      python DataHive -c create -sc <your_schema_path>
    • Sets a row with the provided input data:

      python DataHive -c set -db <your_database> -t <your_table> -q '{"key": "value"}'
    • Utilizes the input query to retrieve specific data from the database:

      python DataHive -c get -db <your_database> -t <your_table> -q '{"key": "value"}'
              # if you didn't add -q it will get all data in the table
    • Uses the input query to delete specific data from the database:

      python DataHive -c delete -db <your_database> -t <your_table> -q '{"key": "value"}'
    • Resets the specified database to its initial state:

      python DataHive -c clear -db <your_database>'

5. FAQs

  • Q1: What is DataHive?

    • A1: DataHive is a lightweight database system designed for storing data in JSON files. It provides essential CRUD (Create, Read, Update, Delete) operations and ensures synchronization between read and write operations. DataHive is an ideal solution for small-scale applications where a simple and reliable data storage system is required.
  • Q2: How do I install DataHive?

    • A2: To install DataHive, you need to have Python 3.x installed on your machine. After ensuring Python is installed, run the following command:

      pip install DataHive
  • Q3: What is the schema format for defining the database structure?

    • A3: The schema format defines the structure of the database, including the database name, tables, and their attributes. It consists of elements like table names, column names, primary keys, index keys, and overwriting settings. You can find a detailed example of the schema format in the Schema Format section of this README.
  • Q4: How do I use the Command-Line Interface (CLI) to interact with DataHive?

    • A4: The CLI offers a set of commands for creating, updating, querying, deleting data, and resetting databases. You can use the general command format:

      python DataHive -c [command] [options]

      Replace [command] with the desired database command and [options] with relevant command options. Examples of various commands can be found in the Example Usage section.

  • Q5: Is DataHive compatible with Java?

    • A5: Yes, DataHive is cross-language compatible. We have developed a dedicated Java driver (SimpleDBDriver) that seamlessly integrates with DataHive. This Java driver allows Java applications to interact with the database, extending its usability to diverse programming ecosystems.

6. Contributing

Contributions to DataHive are welcome! Feel free to fork the repository, make improvements, and create pull requests.

7. License

DataHive is released under the MIT License. See the LICENSE file for details.

8. Upcoming Features

  • Stay tuned for future updates and additional features. We are constantly working on enhancing DataHive to provide an even better data storage solution for your needs.

Note: This documentation provides an overview of DataHive's functionality and usage. For detailed code explanations, refer to the source code and comments in SimpleFSDB's repository.

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%