SQLAlchemyStorage for aiogram FSM
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.
Release files for aiogram-sqlalchemy-storage 0.2.0.post0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiogram_sqlalchemy_storage-0.2.0.post0.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiogram_sqlalchemy_storage-0.2.0.post0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / aiogram_sqlalchemy_storage-0.2.0.post0.tar.gz
| Download URL | aiogram_sqlalchemy_storage-0.2.0.post0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d37c8157766b0542cad3663496b90c53c5b07612817da3b82a79a38937debc0
|
|
BLAKE2b-256 checksum How to use checksums |
e4af1c2cd52636bcf2e1396af8b836059c6b02cae2fded2410366e2278af234e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.10
|
Release files / aiogram_sqlalchemy_storage-0.2.0.post0-py3-none-any.whl
| Download URL | aiogram_sqlalchemy_storage-0.2.0.post0-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3523ae32ad9969412c6871246a019f9408bb4ef4b932c5d0e9bd9a63d5a8c732
|
|
BLAKE2b-256 checksum How to use checksums |
5a1cf6105ec8782c23cca4e6e7996910a554946e26647b649a0f347eb1606ad1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.10
|