Skip to main content

Unlimited Capacity Database For Programming Using Telegram as Database.

Project description

GramDB: Infinite Database Storage via Telegram

=====================================================

Introduction

GramDB is a unique library that leverages Telegram as a database, offering infinite storage capabilities. It provides a robust and efficient way to manage data, making it an ideal solution for applications requiring flexible and scalable data storage.

Features

  • Infinite Storage: Utilize Telegram's messaging capabilities to store data without traditional storage limitations.
  • Real-time Data Access: Fetch, insert, update, and delete data in real-time.
  • Asynchronous Operations: Support for asynchronous operations to ensure non-blocking and efficient data management.
  • Schema Management: Define and manage schemas for tables to ensure data consistency.
  • Background Tasks: Handle background tasks for creating, updating, and deleting data seamlessly.

Installation

To use GramDB, you need to install the library and its dependencies. You can do this via pip:

pip install gramdb

Getting Started

  1. Authentication: Authenticate with your Telegram database URL.
  2. Initialize: Initialize the GramDB instance with the authenticated URL and an asynchronous manager.
  3. Data Operations: Perform CRUD (Create, Read, Update, Delete) operations on your data.

Example Usage

Authentication and Initialization

from gramdb import GramDB, AsyncManager 

# Replace with your actual database URL
db_url = "https://your-telegram-db-url.com"

# Initialize the asynchronous manager
async_manager = AsyncManager()

# Initialize GramDB
gramdb = GramDB(db_url, async_manager)

Creating a Table

# Define the schema for the new table
schema = ["name", "age", "email"]
    
# Create the table
await gramdb.create_one("users", schema)

Inserting Data

# Define the record to insert
record = {
    "name": "John Doe",
    "age": 30,
    "email": "john.doe@example.com"
}
    
# Insert the record
await gramdb.insert_one("users", record)

Fetching Data

# Define the query criteria
query = {
    "name": "John Doe"
}
    
# Fetch the data
result = await gramdb.find_one("users", query)
print(result)

Updating Data

# Define the query criteria and update fields
query = {
    "name": "John Doe"
}
update_fields = {
    "$set": {
        "age": 31
    }
}
    
# Update the data
await gramdb.update_one("users", query, update_fields)

Deleting Data

# Define the query criteria
query = {
    "name": "John Doe"
}
    
# Delete the data
await gramdb.delete_one("users", query)

Methods

Authentication and Initialization

  • __init__(db_url, async_manager): Initialize the GramDB instance with the provided database URL and asynchronous manager.
  • authenticate(): Authenticate with the provided database URL.

Data Operations

  • create_one(table_name, schema): Create a new table with the given schema.
  • insert_one(table_name, record): Insert a new record into the specified table.
  • find(table_name, query): Fetch records from the specified table based on the given query.
  • find_one(table_name, query): Fetch one record from the specified table based on the given query.
  • fetch_all(): Fetch all records from all tables.
  • update_one(table_name, query, update_query): Update records in the specified table based on the given query and update criteria.
  • delete_one(table_name, query): Delete records from the specified table based on the given query.

Background Tasks

  • background_create(table_name, _m_id): Create a new table in the background.
  • background_insert(table_name, _m_id): Insert a new record in the background.
  • background_update(table_name, query, _m_id): Update records in the background.
  • background_delete(table_name, _m_id): Delete a record in the background.
  • background_delete_table(table_name): Delete a table in the background.

Utility Methods

  • wait_for_background_tasks(): Wait for all background tasks to complete.
  • close(): Run async background tasks and close the async manager.

API Documentation

For detailed API documentation, please refer to the API Documentation.

Contributing

Contributions are welcome If you find any issues or have suggestions, please open an issue or submit a pull request.

License

GramDB is licensed under the GPU License.

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

gramdb-2.2.0.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

GramDB-2.2.0-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file gramdb-2.2.0.tar.gz.

File metadata

  • Download URL: gramdb-2.2.0.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for gramdb-2.2.0.tar.gz
Algorithm Hash digest
SHA256 40f0b40ed2cefa0c6d30b62657639ed432062d2cb3f2fb57a02c55df1726a7e5
MD5 d8fd162ab4afad5ee28f7609409ae3c6
BLAKE2b-256 2890c046ef5231f33aafb66db6a9c6df326073766ee794486eee95607e3cbebb

See more details on using hashes here.

File details

Details for the file GramDB-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: GramDB-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for GramDB-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2bcdc021af0a4d7b38f5cfc292f2a65a18639c47b56f557f1f4b8db8d300611
MD5 cf06acffdf4ec3cf97334a2d82c0879e
BLAKE2b-256 6cec6f285c2de04a30519fc1fdae56c32e14ba391803047de7c9d201f3797ee6

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