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

[DH-5724] Fix refresh error handler #459

Merged
merged 1 commit into from
Apr 11, 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
24 changes: 11 additions & 13 deletions dataherald/api/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,18 @@ def refresh_table_description(
try:
sql_database = SQLDatabase.get_sql_engine(db_connection, True)
tables = sql_database.get_tables_and_views()

# Get tables and views and create missing table-descriptions as NOT_SCANNED and update DEPRECATED
scanner_repository = TableDescriptionRepository(self.storage)
scanner = self.system.instance(Scanner)
return [
TableDescriptionResponse(**record.dict())
for record in scanner.refresh_tables(
tables, str(db_connection.id), scanner_repository
)
]
except Exception as e:
raise HTTPException( # noqa: B904
status_code=400,
detail=f"{e}",
)
# Get tables and views and create missing table-descriptions as NOT_SCANNED and update DEPRECATED
scanner_repository = TableDescriptionRepository(self.storage)
scanner = self.system.instance(Scanner)
return [
TableDescriptionResponse(**record.dict())
for record in scanner.refresh_tables(
tables, str(db_connection.id), scanner_repository
)
]
return error_response(e, refresh_table_description.dict(), "refresh_failed")

@override
def list_database_connections(self) -> list[DatabaseConnectionResponse]:
Expand Down
Loading