Skip to content

A database made in python meant to be superfast and easy to learn for beginners and meant to be a sql,sqlite and postgres competitor

License

Notifications You must be signed in to change notification settings

cools9/ElementalDB

Repository files navigation

ElementalDB

ElementalDB Diagram

ElementalDB is a lightweight, easy-to-use database management system implemented in Python. It supports basic functionalities for creating, reading, updating, and deleting (CRUD) tables and their records, along with relationships between tables.

Features

  • Table Creation: Create tables with specified columns.
  • Record Management: Add, update, and delete records in tables.
  • Binary Search: Efficient searching for records based on indexed columns.
  • Data Persistence: Save and load tables to/from BSON files for persistent storage.
  • Relations: Create relationships between tables with options for cascading or restricting actions on related records.

Requirements

  • Python 3.x
  • Various Python Libraries listed in requirements.txt

All the dependent libraries can be installed by running pip install -r requirements.txt

Installation

  1. Clone the repository:

    git clone https://github.com/cools9/ElementalDB
  2. Navigate into the project directory:

    cd ElementalDB
  3. Install the required dependencies:

    pip install -r requirements.txt

Usage

Here’s a basic example of how to use ElementalDB:

import asyncio
from elementaldb import ElementalDB  # Make sure to import your ElementalDB class

async def main():
    db = ElementalDB()
    await db.table_create("users", columns=["username", "password", "email"])
    await db.add('users', [["john_doe", "securepass", "[email protected]"],
                            ["jane_smith", "mypassword", "[email protected]"]])

    # Search for a user
    results = await db.search('users', 'john_doe', 'username')
    print(results)

    # Update a user's information
    await db.update('users', row_number=1, data=["john_doe", "new_securepass", "[email protected]"])

    # Delete a user
    await db.delete('users', row_number=1)

# Run the async main function
asyncio.run(main())

Functions Overview

  • table_create(name, columns, overwrite=False): Creates a new table with the specified name and columns.
  • add(table_name, records): Adds records to the specified table.
  • update(table_name, row_number, data): Updates a specific row in the table.
  • delete(table_name, row_number): Deletes a specific row from the table.
  • search(table_name, what, in_column): Searches for a specific value in the given column.
  • relate(from_table, to_table, on_change='restrict'): Creates a relation between two tables with options for cascading or restricting deletes.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes. Please visit Contribution guides for more information.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

A database made in python meant to be superfast and easy to learn for beginners and meant to be a sql,sqlite and postgres competitor

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages