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

Fix generation of data #213

Merged
merged 2 commits into from
Feb 14, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Third Party
import pyodbc
from sqlalchemy import text
from sqlalchemy.exc import DBAPIError

# First Party
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading