clay
03/22/2023, 5:00 PMdef get_sql_from_file(filename) -> str:
"""
Reads the query in from a SQL file and returns the string
"""
query = ""
__location__ = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(filename))
)
with open(os.path.join(__location__, filename), "r") as sqlfile:
query = sqlfile.read()
return query
@asset(
required_resource_keys={"snowflake"},
compute_kind="Snowflake",
)
def ED_CRM_DASH_CRM_JIRA_CUSTOM_FIELD(context: OpExecutionContext) -> None:
"""
Pull CRM Jira Custom field data.
"""
<http://context.log.info|context.log.info>(glob.glob("*.sql"))
glob.glob("*.sql")
with context.resources.snowflake.get_connection() as conn:
with closing(conn.cursor()) as cursor:
# This works just fine
q0 = "SELECT * FROM MYTABLE"
cursor.execute(q0)
# This does not work
q1 = get_sql_from_file("01_ED_CRM_DASH_CRM_JIRA_CUSTOM_FIELD.sql")
cursor.execute(q1)
return None