Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log all sql queries #173

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading