Skip to main content

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.

Metadata

Release files for GramDB 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GramDB 2.2.0
File Size Uploaded
gramdb-2.2.0.tar.gz 24.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for GramDB 2.2.0
File Interpreter ABI Platform
GramDB-2.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 48.8 kB

Release files / gramdb-2.2.0.tar.gz

Download URL gramdb-2.2.0.tar.gz
Size 24.5 kB
Tags Source
SHA-256 checksum
How to use checksums
40f0b40ed2cefa0c6d30b62657639ed432062d2cb3f2fb57a02c55df1726a7e5
BLAKE2b-256 checksum
How to use checksums
2890c046ef5231f33aafb66db6a9c6df326073766ee794486eee95607e3cbebb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / GramDB-2.2.0-py3-none-any.whl

Download URL GramDB-2.2.0-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2bcdc021af0a4d7b38f5cfc292f2a65a18639c47b56f557f1f4b8db8d300611
BLAKE2b-256 checksum
How to use checksums
6cec6f285c2de04a30519fc1fdae56c32e14ba391803047de7c9d201f3797ee6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.2

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page