From 74d0c760380d1560eb3e4b0b0a31018bbbcdab54 Mon Sep 17 00:00:00 2001 From: Benoit Viguier Date: Wed, 17 Jan 2024 14:54:49 +0100 Subject: [PATCH 1/2] fix generation of data --- .../src/resc_backend/bin/dummy-data-generator/db_util.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/resc-backend/src/resc_backend/bin/dummy-data-generator/db_util.py b/components/resc-backend/src/resc_backend/bin/dummy-data-generator/db_util.py index c47c8967..3a1d6216 100644 --- a/components/resc-backend/src/resc_backend/bin/dummy-data-generator/db_util.py +++ b/components/resc-backend/src/resc_backend/bin/dummy-data-generator/db_util.py @@ -5,6 +5,7 @@ # Third Party import pyodbc from sqlalchemy.exc import DBAPIError +from sqlalchemy import text # First Party from resc_backend.common import initialise_logs @@ -12,7 +13,7 @@ from resc_backend.db.connection import Session, engine from resc_backend.db.model import Base -CONNECTION_CHECK_QUERY = "select 1 from finding" +CONNECTION_CHECK_QUERY = text("select 1 from finding") RESC_DB_MODEL_MODULE = "resc_backend.db.model" logger_config = initialise_logs(LOG_FILE_DUMMY_DATA_GENERATOR) @@ -82,7 +83,7 @@ def get_data_for_single_attr(self, klass: Base, attr: str): specified attribute of the class 'klass'. ex: id_, name, version""" try: - return [r.__getitem__(attr) for r in self.session.query(klass.__getattribute__(klass, attr))] + return [r[0] for r in self.session.query(klass.__getattribute__(klass, attr))] except AttributeError as ex: logger.error(f"{klass} does not have any attribute [{attr}].") self.handle_and_exit(ex) From c323f32cec7b025f463a9268d66a5459d37e2e01 Mon Sep 17 00:00:00 2001 From: Benoit Viguier Date: Tue, 13 Feb 2024 18:33:17 +0100 Subject: [PATCH 2/2] fix linting --- .../src/resc_backend/bin/dummy-data-generator/db_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/resc-backend/src/resc_backend/bin/dummy-data-generator/db_util.py b/components/resc-backend/src/resc_backend/bin/dummy-data-generator/db_util.py index 3a1d6216..d350b646 100644 --- a/components/resc-backend/src/resc_backend/bin/dummy-data-generator/db_util.py +++ b/components/resc-backend/src/resc_backend/bin/dummy-data-generator/db_util.py @@ -4,8 +4,8 @@ # Third Party import pyodbc -from sqlalchemy.exc import DBAPIError from sqlalchemy import text +from sqlalchemy.exc import DBAPIError # First Party from resc_backend.common import initialise_logs