Обновить clickhouse_dag.py

This commit is contained in:
2025-09-18 16:42:40 +04:00
parent 8c4dec9a05
commit 0f08dbdeb3

View File

@@ -1,18 +1,21 @@
from airflow import DAG
from airflow.providers.http.operators.http import SimpleHttpOperator
from datetime import datetime
from urllib.parse import urlencode
with DAG(
dag_id="clickhouse_list_tables",
start_date=datetime(2025, 1, 1),
schedule_interval=None,
catchup=False,
) as dag:
list_tables = SimpleHttpOperator(
task_id="list_tables",
http_conn_id="clickhouse_http", # Connection в Airflow
endpoint="/",
endpoint="/", # ClickHouse HTTP
method="POST",
data={"query": "SHOW TABLES"},
data=urlencode({"query": "SHOW TABLES"}), # Нужно как x-www-form-urlencoded
headers={"Content-Type": "application/x-www-form-urlencoded"},
log_response=True, # покажет результат в логах Airflow
)
)