SQLiteStorage

Persistent FSM storage with zero infrastructure. v0.5.0

Setup

main.py
from kurigram_addons import KurigramClient, SQLiteStorage

app = KurigramClient(
    "my_bot",
    bot_token="...",
    storage=SQLiteStorage("fsm.db"),
)
app.run()

Requires the aiosqlite package: pip install kurigram-addons[sqlite]

Constructor Parameters

ParameterTypeDefaultDescription
pathstr | PathPath to the SQLite database file
tablestr"fsm_state"Table name for state records
cleanup_intervalint300Seconds between TTL cleanup runs

Characteristics

  • Survives bot restarts — state persists on disk.
  • compare_and_set is atomic via BEGIN IMMEDIATE transactions.
  • increment() is implemented as a single SQL INSERT … ON CONFLICT … DO UPDATE.
  • No extra infrastructure — just a local file.
  • Good for single-process bots. For multi-process deployments, use RedisStorage.

Comparison

BackendPersistentMulti-processExtra infra
MemoryStorageNoNoNone
SQLiteStorageYesNoNone
RedisStorageYesYesRedis