Unresolved attribute reference 'transaction' for class 'Pool' Asyncpg
Пытаюсь обернуть несколько запросов бд в транзакцию, но получаю ошибку. Весь код:
class DbSession(BaseMiddleware):
def __init__(self, connector: asyncpg.pool.Pool):
super().__init__()
self.connector = connector
async def __call__(
self,
handler: Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]],
event: TelegramObject,
data: Dict[str, Any],
) -> Any:
async with self.connector.acquire() as connect:
data['request'] = Request(connect)
return await handler(event, data)
class Request:
def __init__(self, connector: asyncpg.pool.Pool):
self.connector = connector
async def function(self):
async with self.connection.transaction(): # Ошибка
(запросы)
async def create_pool():
return await asyncpg.create_pool(user='postgres', database='csbotdata',
host='localhost', port='5432',
password='123')
async def main():
dp.update.middleware.register(DbSession(await create_pool()))