diff --git a/data/h3_data_importer/utils.py b/data/h3_data_importer/utils.py index 6e9f53e19..22e9a3e05 100644 --- a/data/h3_data_importer/utils.py +++ b/data/h3_data_importer/utils.py @@ -127,7 +127,7 @@ def get_metadata(table: str) -> dict: return metadata -def link_to_indicator_table(connection: connection, indicator_code: str, h3_column_name: str): +def link_to_indicator_table(connection: connection, indicator_code: str, h3_table_name: str, h3_column_name: str): """Gets indicatorID and links it to the h3table corresponding entry""" with connection: with connection.cursor() as cursor: @@ -136,9 +136,9 @@ def link_to_indicator_table(connection: connection, indicator_code: str, h3_colu if indicator_id: cursor.execute( f"""update "h3_data" set "indicatorId" = '{indicator_id}' - where "h3columnName" = '{h3_column_name}'""" + where "h3tableName" = '{h3_table_name}' and "h3columnName" = '{h3_column_name}'""" ) - log.info(f"Updated indicatorId '{indicator_id}' in h3_data for {h3_column_name}") + log.info(f"Updated indicatorId '{indicator_id}' in h3_data for {h3_table_name}.{h3_column_name}") else: log.error(f"Indicator with name code {indicator_code} does not exist") diff --git a/data/h3_data_importer/vector_folder_to_h3_table.py b/data/h3_data_importer/vector_folder_to_h3_table.py index 3faa6da4d..71960ba5a 100644 --- a/data/h3_data_importer/vector_folder_to_h3_table.py +++ b/data/h3_data_importer/vector_folder_to_h3_table.py @@ -190,7 +190,7 @@ def main( return # gracefully exit without exception if indicator_code: # if given, consider layer as indicator update h3_table - link_to_indicator_table(conn, indicator_code, column) + link_to_indicator_table(conn, indicator_code, table, column) postgres_thread_pool.putconn(conn, close=True)