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..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,6 +4,7 @@ # Third Party import pyodbc +from sqlalchemy import text from sqlalchemy.exc import DBAPIError # First Party @@ -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)