"""Snowflake connection adapter.""" from functools import cache import snowflake.connector from snowflake.connector import DictCursor from src import config @cache def snowflake_connection(): return snowflake.connector.connect( user=config.SNOWFLAKE_USER_NAME, account=config.SNOWFLAKE_ACCOUNT, database=config.SNOWFLAKE_DATABASE, schema=config.SNOWFLAKE_SCHEMA, role=config.SNOWFLAKE_ROLE, private_key=config.SNOWFLAKE_PRIVATE_KEY, ) def query(sql_query): """Execute a query against Snowflake.""" conn = snowflake_connection() cursor = conn.cursor(DictCursor) return cursor.execute(sql_query)