KeyError:“变量xxl_credential不存在”

时间:2019-10-22 08:49:35

标签: python variables airflow airflow-scheduler airflow-operator

我正在尝试检查气流是否存在问题,但遇到错误KeyError: 'Variable xxl_credential does not exist'。当我尝试通过UI创建变量时,它正在显示,但是一段时间后消失了。当我想添加代码时,它仍然会抛出相同的错误。我的代码如下:

def get_data_from_GBQ():
    global customer_data
    customer_data_query = """ SELECT addressShippingName, email, mobile FROM `xxlhoreca-bi.DataImport.orders` where mobile <> "" LIMIT 2 """

    # Creating a connection to the google bigquery
    client = bigquery.Client.from_service_account_json(xxl_credential_var)
    customer_data = client.query(customer_data_query).to_dataframe()
    print(customer_data)

xxl_credential = "C:/Users/nazrin.guliyeva/Documents/GitHub/airflow-tutorial/examples/intro-example/credentials/cred_xxl.json"
xxl_credential_var = Variable.get("xxl_credential")

dag = DAG(
    'odoo_connection_dag',
    default_args=default_args,
    description='A connection between ',
    schedule_interval=timedelta(days=1),
    template_searchpath = xxl_credential_var,
)

# t1, t2 are examples of tasks created by instantiating operators
t1 = PythonOperator(
    task_id='get_data_from_gbq',
    python_callable=get_data_from_GBQ,
    dag=dag,
)

0 个答案:

没有答案