

XCom.execution_date = execution_date).all() XCom.dag_id = dag_id, XCom.task_id = task_id, Xcoms: List = session.query(XCom).filter( :param session: Airflow's SQLAlchemy Session (this param must not be passed, it will be automatically supplied decorator) Session: Optional) -> List:įunction that reads and returns 'values' of XCOMs with given filters

#Airflow xcom code
Here's an untested code snippet for referenceįrom import provide_sessionįrom pendulum import read_xcom_values(dag_id: str, (without having to create a task or DAG). So you want to access XCOM outside Airflow (probably a different project / module, without creating any Airflow DAGs / tasks)?Īirflow uses SQLAlchemy for mapping all it's models (including XCOM) to corresponding SQLAlchemy backend (meta-db) tables Now I would like to pass this value to some python function sql_file_template without using PythonOperator.Īs per Airflow documentation xcom can be accessed only between tasks. The output of stored proc is a string which is captured using xcom. Task_instance.xcom_push(key='query_string', value=result) Query = query.format(kwargs,kwargs ,kwargs,kwargs,kwargs) Query = """CALL `.dataset_name.store_proc`(

I have a stored XCom value that I wanted to pass to another python function which is not called using PythonOperator.
