data.py 455 B

1234567891011121314151617181920
  1. from aiosqlite import Connection
  2. from ..types import Message, Context
  3. from .base import InjectorWithCleanup
  4. __all__ = [
  5. "Database",
  6. ]
  7. class DatabaseInjector(InjectorWithCleanup[Connection]):
  8. async def inject(self, message: Message, context: Context) -> Connection:
  9. return await context.database()
  10. async def cleanup(self, conn: Connection):
  11. await conn.close()
  12. Database = DatabaseInjector()
  13. # TODO data store for blob data