From c67abf2c1a70b5bb4716efcea79f9695b77a7a9b Mon Sep 17 00:00:00 2001 From: spicy-sauce Date: Wed, 7 Aug 2024 13:46:57 +0300 Subject: [PATCH] distinguish errors --- core/src/datayoga_core/blocks/relational/write/block.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/datayoga_core/blocks/relational/write/block.py b/core/src/datayoga_core/blocks/relational/write/block.py index 153de4e2..b0d42fd5 100644 --- a/core/src/datayoga_core/blocks/relational/write/block.py +++ b/core/src/datayoga_core/blocks/relational/write/block.py @@ -173,8 +173,10 @@ def execute(self, statement: Any, records: List[Dict[str, Any]]): statement = text(statement) logger.debug(f"Executing {statement} on {records}") + connected = False try: with self.engine.connect() as connection: + connected = True try: connection.execute(statement, records) if not connection._is_autocommit_isolation(): @@ -182,7 +184,8 @@ def execute(self, statement: Any, records: List[Dict[str, Any]]): except Exception: raise except Exception as e: - raise ConnectionError(e) from e + if not connected: + raise ConnectionError(e) from e def execute_upsert(self, records: List[Dict[str, Any]]): """Upserts records into the table."""