SQLAlchemy-based storage for aiogram FSM
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiogram_sqlalchemy_storage-0.2.0.post0.tar.gz.
File metadata
- Download URL: aiogram_sqlalchemy_storage-0.2.0.post0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d37c8157766b0542cad3663496b90c53c5b07612817da3b82a79a38937debc0
|
|
| MD5 |
094a7d60c97fbb9a7db8b176912f9a3d
|
|
| BLAKE2b-256 |
e4af1c2cd52636bcf2e1396af8b836059c6b02cae2fded2410366e2278af234e
|
File details
Details for the file aiogram_sqlalchemy_storage-0.2.0.post0-py3-none-any.whl.
File metadata
- Download URL: aiogram_sqlalchemy_storage-0.2.0.post0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3523ae32ad9969412c6871246a019f9408bb4ef4b932c5d0e9bd9a63d5a8c732
|
|
| MD5 |
4ca797e70c1ca80be9237ae2bb5bfd5f
|
|
| BLAKE2b-256 |
5a1cf6105ec8782c23cca4e6e7996910a554946e26647b649a0f347eb1606ad1
|