Skip to main content

aiogram YDB Storage

aiogram_ydb_storage is a storage implementation for aiogram FSM that utilizes Yandex Database (YDB) as the storage backend. This allows you to persist state data for state machines used in your Telegram bots.

Installation

You can install aiogram_ydb_storage via pip:

pip install aiogram_ydb_storage

Usage

To use aiogram_ydb_storage, you need to first set up your YDB database and obtain necessary credentials. Then, you can use it in conjunction with aiogram as follows:

import asyncio
from aiogram import Bot, Dispatcher, types
from aiogram.filters import CommandStart
from aiogram.types import Message
from aiogram.fsm.context import FSMContext
from aiogram.fsm.state import StatesGroup, State

import ydb
from aiogram_ydb_storage import YDBStorage

# Configure YDB driver
driver_config = ydb.DriverConfig(
    "grpcs://...",  # YDB endpoint
    "...",          # Database name
    credentials=ydb.credentials_from_env_variables(),  # Use YDB credentials from environment
)

# Initialize YDBStorage
my_storage = YDBStorage(driver_config=driver_config)

# Initialize aiogram Bot and Dispatcher
dp = Dispatcher(storage=my_storage)
bot = Bot("token")

# Define your states
class MyStates(StatesGroup):
    test1 = State()
    test2 = State()

# Handlers
@dp.message(CommandStart())
async def command_start_handler(message: Message, state: FSMContext) -> None:
    await state.set_state(MyStates.test1)
    await message.answer("Set state test1")

@dp.message(MyStates.test1)
async def handler(message: types.Message, state: FSMContext) -> None:
    await message.answer("state test1. Set state test2")
    await state.set_state(MyStates.test2)

@dp.message()
async def echo_handler(message: types.Message, state: FSMContext) -> None:
    await message.answer("not state test1. Set state test1")
    await state.set_state(MyStates.test1)

# Main function
async def main() -> None:
    await dp.start_polling(bot)

# Run the main function
if __name__ == "__main__":
    asyncio.run(main())

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for aiogram-ydb-storage 0.1.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 aiogram-ydb-storage 0.1.0
File Size Uploaded Provenance Actions
aiogram_ydb_storage-0.1.0.tar.gz 4.3 kB Without provenance Details for aiogram_ydb_storage-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiogram-ydb-storage 0.1.0
File Interpreter ABI Platform Actions
aiogram_ydb_storage-0.1.0-py3-none-any.whl Python 3 none any Details for aiogram_ydb_storage-0.1.0-py3-none-any.whl

Total release size: 9.4 kB

Release files / aiogram_ydb_storage-0.1.0.tar.gz

Download URL aiogram_ydb_storage-0.1.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7a01fac447b45a87d613847ced129dab121003366ab9784502682acc9dfe8145
BLAKE2b-256 checksum
How to use checksums
d839077752d9c84087a766fc9148b8aed4f799be8576b63dcbc928374e60ce76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.12.1 Windows/11

Release files / aiogram_ydb_storage-0.1.0-py3-none-any.whl

Download URL aiogram_ydb_storage-0.1.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55a5e95c5ea194f17c4aae1924963c519d34dca5a512008ad209dc5362236058
BLAKE2b-256 checksum
How to use checksums
44319c9ee4a235fe264fb7f287048b1d375099b097ee8795282b7e5429936626
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.12.1 Windows/11

Security for aiogram-ydb-storage 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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