import config if config.LOCK_TERRITORIES: count_backfill_query = """ SELECT count(id) as total FROM {} WHERE derived_ownership != 'ERROR' AND derived_tuid IS NOT NULL AND is_locked = 1 AND (ioda_compare_cat NOT IN ('C', 'D') OR ioda_compare_cat is NULL) """.format(config.TARGET_MAPPED_ASSETS) select_backfill_query = """ SELECT id, filename, isrc, derived_tuid, derived_ownership FROM {} WHERE derived_ownership != 'ERROR' AND derived_tuid IS NOT NULL AND is_locked = 1 AND (ioda_compare_cat NOT IN ('C', 'D') OR ioda_compare_cat is NULL) LIMIT :limit OFFSET :offset """.format(config.TARGET_MAPPED_ASSETS) else: count_backfill_query = """ SELECT count(id) as total FROM {} WHERE derived_ownership != 'ERROR' AND derived_tuid IS NOT NULL AND (ioda_compare_cat NOT IN ('C', 'D') OR ioda_compare_cat is NULL) """.format(config.TARGET_MAPPED_ASSETS) select_backfill_query = """ SELECT id, filename, isrc, derived_tuid, derived_ownership FROM {} WHERE derived_ownership != 'ERROR' AND derived_tuid IS NOT NULL AND (ioda_compare_cat NOT IN ('C', 'D') OR ioda_compare_cat is NULL) LIMIT :limit OFFSET :offset """.format(config.TARGET_MAPPED_ASSETS) insert_error = """ INSERT INTO mr_backfill_sqs_error VALUES (:id, :filename, :isrc, :derived_tuid, :derived_ownership) """ truncate_error_table = """ TRUNCATE mr_backfill_sqs_error """