From 632569a13521e6769ebe8bc4339c4f39a519be4f Mon Sep 17 00:00:00 2001 From: timofey Date: Tue, 1 Nov 2022 03:36:43 +0000 Subject: [PATCH] now Db works like it did --- ptvp35/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ptvp35/__init__.py b/ptvp35/__init__.py index d67831b..b14f0e3 100644 --- a/ptvp35/__init__.py +++ b/ptvp35/__init__.py @@ -301,3 +301,10 @@ class Db(DbFactory, DbConnection): def __init__(self, path: str | pathlib.Path, *, kvrequest_type: Type[KVRequest], buffersize=1048576): DbFactory.__init__(self, path, kvrequest_type=kvrequest_type, buffersize=buffersize) DbConnection.__init__(self, self) + + async def __aenter__(self): + await self._initialize() + return self + + async def __aexit__(self, exc_type, exc_val, exc_tb): + await self.aclose()