Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
584 views
in Technique[技术] by (71.8m points)

python - sqlite syntax error with simple task on apache airflow-2.0

i have just installed apache airflow according to the following steps:

  1. pip install "apache-airflow[celery, crypto, postgres, mysql, rabbitmq, redis]" --constraint constraints-3.7.txt
  2. airflow db init
  3. mkdir airflow/dags
  4. Set to False the load_examples variables at airflow.cfg file.
  5. Created a user.

I'm using a Ubuntu 16.04.6 LTS VM and a virtual enviroment with Python 3.7.8 installed.

~$ sqlite3 --version 
3.11.0
>>> import sqlite3
>>> sqlite3.version
'2.6.0'

My dag inside the dags folder is the following:

from airflow import DAG
from airflow.operators.dummy_operator import DummyOperator
from airflow.operators.python_operator import PythonOperator

from time import sleep
from datetime import datetime

def print_hello():
        sleep(5)
        return 'Hello World'

with DAG('hello_world_dag', description='First DAG', schedule_interval='*/10 * * * *', start_date=datetime(2018, 11, 1), catchup=False) as dag:
        dummy_task      = DummyOperator(task_id='dummy_task', retries=3)
        python_task     = PythonOperator(task_id='python_task', python_callable=print_hello)

        dummy_task >> python_task

At the execution dummy task runs perfectly, otherwise, python task throws this error:

[2020-12-31 12:23:27,493] {taskinstance.py:1396} ERROR - (sqlite3.OperationalError) near ",": syntax error
[SQL: DELETE FROM rendered_task_instance_fields WHERE rendered_task_instance_fields.dag_id = ? AND rendered_task_instance_fields.task_id = ? AND (rendered_task_instance_fields.dag_id, rendered_task_instance_fields.task_id, rendered_task_instance_fields.execution_date) NOT IN (SELECT rendered_task_instance_fields.dag_id, rendered_task_instance_fields.task_id, rendered_task_instance_fields.execution_date 
FROM rendered_task_instance_fields 
WHERE rendered_task_instance_fields.dag_id = ? AND rendered_task_instance_fields.task_id = ? ORDER BY rendered_task_instance_fields.execution_date DESC
 LIMIT ? OFFSET ?)]
[parameters: ('hello_world_dag', 'python_task', 'hello_world_dag', 'python_task', 30, 0)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
Traceback (most recent call last):
  File "/home/vagrant/.sandbox/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/vagrant/.sandbox/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: near ",": syntax error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...