From ec156b89b7537760f84239c9ef4576e5d52fa324 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 8 Oct 2020 14:29:57 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=99=20Add=20Session=20to=20Alchemist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- royalnet/alchemist/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/royalnet/alchemist/__init__.py b/royalnet/alchemist/__init__.py index 6ec7f7c3..1050b2d3 100644 --- a/royalnet/alchemist/__init__.py +++ b/royalnet/alchemist/__init__.py @@ -1,5 +1,6 @@ from royalnet.typing import * import sqlalchemy as sa +import sqlalchemy.orm as saorm __all__ = ( @@ -14,6 +15,7 @@ class Alchemist: engine_args: Iterable[Any], engine_kwargs: Mapping[str, Any]): self.engine: sa.engine.Engine = sa.create_engine(*engine_args, **engine_kwargs) + self.Session: Union[saorm.sessionmaker, Type[saorm.Session]] = saorm.sessionmaker(bind=self.engine) def add_metadata(self, metadata: sa.MetaData): """Bind a MetaData object to the engine, and create all tables linked with it."""