Skip to content

Commit

Permalink
distinguish errors
Browse files Browse the repository at this point in the history
  • Loading branch information
spicy-sauce committed Aug 7, 2024
1 parent 04aeb2e commit c67abf2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/datayoga_core/blocks/relational/write/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,19 @@ 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():
connection.commit()
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."""
Expand Down

0 comments on commit c67abf2

Please sign in to comment.