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()