diff --git a/dataherald/db_scanner/sqlalchemy.py b/dataherald/db_scanner/sqlalchemy.py index 2badd775..dd8305d2 100644 --- a/dataherald/db_scanner/sqlalchemy.py +++ b/dataherald/db_scanner/sqlalchemy.py @@ -64,28 +64,23 @@ def refresh_tables( metadata: dict = None, ) -> list[TableDescription]: stored_tables = repository.find_by({"db_connection_id": str(db_connection_id)}) - stored_tables_list = [table.table_name for table in stored_tables] rows = [] for table_description in stored_tables: if table_description.table_name not in tables: table_description.status = TableDescriptionStatus.DEPRECATED.value rows.append(repository.save_table_info(table_description)) - else: - rows.append(TableDescription(**table_description.dict())) - for table in tables: - if table not in stored_tables_list: - rows.append( - repository.save_table_info( - TableDescription( - db_connection_id=db_connection_id, - table_name=table, - status=TableDescriptionStatus.NOT_SCANNED.value, - metadata=metadata, - ) + rows.append( + repository.save_table_info( + TableDescription( + db_connection_id=db_connection_id, + table_name=table, + status=TableDescriptionStatus.NOT_SCANNED.value, + metadata=metadata, ) ) + ) return rows @override diff --git a/dataherald/sql_database/models/types.py b/dataherald/sql_database/models/types.py index bb47228e..c4ed5b5c 100644 --- a/dataherald/sql_database/models/types.py +++ b/dataherald/sql_database/models/types.py @@ -89,7 +89,7 @@ class DatabaseConnection(BaseModel): @classmethod def validate_uri(cls, input_string): - pattern = r"([^:/]+)://([^/]+)/([^/]+)" + pattern = r"([^:/]+):/+([^/]+)/([^/]+)" match = re.match(pattern, input_string) if not match: raise InvalidURIFormatError(f"Invalid URI format: {input_string}")