Skip to content

Commit

Permalink
[DH-5724] Fix refresh error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jcjc712 committed Apr 10, 2024
1 parent a11d1f1 commit ed5c67c
Showing 1 changed file with 11 additions and 13 deletions.
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

0 comments on commit ed5c67c

Please sign in to comment.