"""Report import models.""" from snowflake_connector.etl_connector import SQLLoader from constants import general import common_config import config sql_loader = SQLLoader(__file__) def import_overlap_report(snowflake_executor, date, csv_key, xls_key): """Import overlap report into Snowflake. Args: snowflake_executor (SnowflakeSQLExecutor): snowflake executor instance date (str): import date csv_key (str): csv report file S3 key xls_key (str): source xls report file S3 key """ s3_path = f's3://{common_config.S3_BUCKET}/{csv_key}' query_params = { 'db': common_config.SNOWFLAKE_CONFIG['db'], 'schema': common_config.SNOWFLAKE_CONFIG['schema'], 'warehouse': common_config.SNOWFLAKE_CONFIG['warehouse'], 'table': config.TABLE_NAME, 's3_path': s3_path, 'aws_access_key_id': common_config.AWS_ACCESS_KEY_ID, 'aws_secret_access_key': common_config.AWS_SECRET_ACCESS_KEY, 'import_date': date, 'report_file': xls_key } with snowflake_executor: snowflake_executor.execute_query( sql_loader, general.CREATE_STAGE_QUERY, query_params) snowflake_executor.execute_query( sql_loader, general.IMPORT_QUERY, query_params) snowflake_executor.execute_query( sql_loader, general.SET_DATE_AND_REPORT_NAME_QUERY, query_params)