오지's blog

airflow에서 select값을 가져오는 방법 본문

개발노트/데이터베이스

airflow에서 select값을 가져오는 방법

오지구영ojjy90 2023. 4. 18. 10:52
728x90
반응형
sf_hook = SnowflakeHook(snowflake_conn_id="SNOWFLAKE_CONN_ID")
sql = f"SELECT DISTINCT(REPLACE(SUBSTR({date_column_name}, 1, 10),'-', '')) FROM {table_name} WHERE SUBSTR({date_column_name}, 1, 10)='{yesterday.strftime(date_string)}';"

conn = sf_hook.get_conn()
cursor = conn.cursor()
cursor.execute(sql)

result = cursor.fetchone()

 

참고

https://stackoverflow.com/questions/53565834/fetch-results-from-bigqueryoperator-in-airflow

 

Fetch results from BigQueryOperator in airflow

I am trying to fetch results from BigQueryOperator using airflow but I could not find a way to do it. I tried calling the next() method in the bq_cursor member (available in 1.10) however it return...

stackoverflow.com

 

 

Comments