Skip to content

Commit

Permalink
Add logging of all sql queries (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFehring committed Feb 28, 2024
1 parent eac6189 commit 34afe33
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Changelog
v1.4.? (??.??.2024)
===================

Feature
-------

- Add logging whenever a sql statement is executed.

Fix
---

Expand Down
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "py-experimenter"
version = "1.4.1a0"
version = "1.4.1a1"
description = "The PyExperimenter is a tool for the automatic execution of experiments, e.g. for machine learning (ML), capturing corresponding results in a unified manner in a database."
authors = [
"Tanja Tornede <t.tornede@ai.uni-hannover.de>",
Expand Down

0 comments on commit 34afe33

Please sign in to comment.