Skip to content

Commit

Permalink
log count for impacted rows (#4864)
Browse files Browse the repository at this point in the history
  • Loading branch information
djnakabaale authored Jan 10, 2024
1 parent 1f399b3 commit 03d5006
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion koku/masu/database/report_db_accessor_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,20 @@ def _prepare_and_execute_raw_sql_query(self, table, tmp_sql, tmp_sql_params=None
def _execute_raw_sql_query(self, table, sql, bind_params=None, operation="UPDATE"):
"""Run a SQL statement via a cursor."""
LOG.info(log_json(msg=f"triggering {operation}", table=table))
row_count = None
with connection.cursor() as cursor:
cursor.db.set_schema(self.schema)
t1 = time.time()
try:
cursor.execute(sql, params=bind_params)
row_count = cursor.rowcount
except OperationalError as exc:
db_exc = get_extended_exception_by_type(exc)
LOG.error(log_json(os.getpid(), msg=str(db_exc), context=db_exc.as_dict()))
raise db_exc from exc

running_time = time.time() - t1
LOG.info(log_json(msg=f"finished {operation}", table=table, running_time=running_time))
LOG.info(log_json(msg=f"finished {operation}", row_count=row_count, table=table, running_time=running_time))

def _execute_trino_raw_sql_query(self, sql, *, sql_params=None, context=None, log_ref=None, attempts_left=0):
"""Execute a single trino query returning only the fetchall results"""
Expand Down

0 comments on commit 03d5006

Please sign in to comment.