import config import snowflake.connector from utils.snowflake.gras_data.queries import ProductFamiliesQuery from utils.snowflake.models import GRASProductsQueryResult from projects.repositories.unclaimed_projects_repository import UnclaimedProjectsRepository class ProductFamiliesImporter: def __init__(self): self.snowflake_connector = snowflake.connector.connect( user=config.SNOWFLAKE_USER, password=config.SNOWFLAKE_PASS, account=config.SNOWFLAKE_ACCOUNT, database=config.PROJECTS_SNOWFLAKE_DB, schema=config.PROJECTS_SNOWFLAKE_SCHEMA, warehouse=config.SNOWFLAKE_WAREHOUSE, ) def fetch(self): with self.snowflake_connector as con: external_ids = UnclaimedProjectsRepository().get_available_gras_projects_ids() data = con.cursor().execute(ProductFamiliesQuery().fetch_products_info(external_ids)).fetchall() return [GRASProductsQueryResult._make(result) for result in data]