diff --git a/core/src/datayoga_core/blocks/relational/write/block.py b/core/src/datayoga_core/blocks/relational/write/block.py index 4bb79ef4..049c2f22 100644 --- a/core/src/datayoga_core/blocks/relational/write/block.py +++ b/core/src/datayoga_core/blocks/relational/write/block.py @@ -27,6 +27,7 @@ def init(self, context: Optional[Context] = None): self.context = context self.engine = None + self.connection = None self.setup_engine() def setup_engine(self): @@ -228,7 +229,7 @@ def _is_connection_valid(self) -> bool: def _handle_connection_error(self, error: Exception): """Handles connection errors by disposing the engine if necessary and raising ConnectionError.""" - if not self._is_connection_valid(): + if self.connection is not None and not self._is_connection_valid(): self.dispose_engine() raise ConnectionError(error) else: