"""Sql2sf configuration.""" from os import environ STATUS_TABLE = environ.get( 'SQL2SF_STATUS_TABLE', 'dev_sql2sf_table_sync_status') FRESHNESS_METRIC_NAME = 'most_recent_sync' # list of syncing table that we want to track SOURCES = [ { 'schema_name': 'stmt-db', 'tables': [ { 'table_name': 'dig_sales_period_id', 'only_business_days': False, 'freshness_threshold': 4 }, { 'table_name': 'remaps', 'only_business_days': False, 'freshness_threshold': 4 }, { 'table_name': 'dmgi_match', 'only_business_days': False, 'freshness_threshold': 4 }, { 'table_name': 'fx_rates', 'only_business_days': False, 'freshness_threshold': 4 }, { 'table_name': 'fx_rates_payout', 'only_business_days': False, 'freshness_threshold': 4 }, { 'table_name': 'snowflake_resolutions', 'only_business_days': False, 'freshness_threshold': 4 }, { 'table_name': 'red_vendors', 'only_business_days': False, 'freshness_threshold': 4 }, { 'table_name': 'supply_chain_vendors', 'only_business_days': False, 'freshness_threshold': 4 }, { 'table_name': 'bad_upc', 'only_business_days': False, 'freshness_threshold': 4 } ] } ] def get_table_config(schema_name, table_name): """Look for table config. Args: schema_name (str): the table's schema. table_name (str): the table's name. Returns: dict: table's configuration. Raises: Exception: if could not find specified table. """ for schema in SOURCES: if not schema_name == schema['schema_name']: continue for table in schema['tables']: if not table_name == table['table_name']: continue return table raise Exception('No table found: {}:{}'.format(schema_name, table_name))