Skip to main content

SQLAlchemy-based storage for aiogram FSM

Project description

SQLAlchemyStorage for aiogram FSM

GitHub Actions Workflow Status

PyPI - License

PyPI - Version

PyPI - Wheel

Overview

SQLAlchemyStorage is a storage backend for aiogram's finite state machine (FSM) using SQLAlchemy. It provides an efficient and flexible way to persist FSM state and data using an asynchronous database session.

Installation

Use pip to install in your environment:

pip install aiogram-sqlalchemy-storage

Quick Start

from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker
from sqlalchemy.orm import declarative_base
from sqlalchemy_storage import SQLAlchemyStorage
from aiogram import Bot, Dispatcher

# Setup database
engine = create_async_engine("sqlite+aiosqlite:///database.db")
SessionLocal = async_sessionmaker(bind=engine, class_=AsyncSession, expire_on_commit=False)
Base = declarative_base()

# Initialize storage
storage = SQLAlchemyStorage(sessionmaker=SessionLocal, metadata=Base.metadata)

# Setup bot
bot = Bot(token="YOUR_BOT_TOKEN")
dp = Dispatcher(storage=storage)

Features

  • Asynchronous support with AsyncSession
  • Customizable table name for storing FSM data
  • Pluggable key-building strategy
  • JSON serialization customization

Documentation

For detailed documentation, configuration options, and advanced usage, see:

Change Log

License

MIT License

Contributions

Contributions are welcome! Feel free to submit issues or pull requests on the repository.

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

aiogram_sqlalchemy_storage-0.2.0.post0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file aiogram_sqlalchemy_storage-0.2.0.post0.tar.gz.

File metadata

File hashes

Hashes for aiogram_sqlalchemy_storage-0.2.0.post0.tar.gz
Algorithm Hash digest
SHA256 0d37c8157766b0542cad3663496b90c53c5b07612817da3b82a79a38937debc0
MD5 094a7d60c97fbb9a7db8b176912f9a3d
BLAKE2b-256 e4af1c2cd52636bcf2e1396af8b836059c6b02cae2fded2410366e2278af234e

See more details on using hashes here.

File details

Details for the file aiogram_sqlalchemy_storage-0.2.0.post0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiogram_sqlalchemy_storage-0.2.0.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 3523ae32ad9969412c6871246a019f9408bb4ef4b932c5d0e9bd9a63d5a8c732
MD5 4ca797e70c1ca80be9237ae2bb5bfd5f
BLAKE2b-256 5a1cf6105ec8782c23cca4e6e7996910a554946e26647b649a0f347eb1606ad1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page