Skip to content

Commit

Permalink
Add logging to database query
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFehring authored and tornede committed Feb 28, 2024
1 parent 18dcb9a commit 65ea617
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions py_experimenter/database_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ def commit(self, connection) -> None:
def execute(self, cursor, sql_statement, values=None) -> None:
try:
if values is None:
self.logger.debug(f"Executing sql statement: {sql_statement}")
cursor.execute(sql_statement)
else:
self.logger.debug(f"Executing sql statement: {sql_statement} with prepared statement values: {values}")
cursor.execute(sql_statement, values)
except Exception as e:
raise DatabaseConnectionError(f"error \n{e}\n raised when executing sql statement.")
Expand Down

0 comments on commit 65ea617

Please sign in to comment.