Обновить clickhouse_dag.py
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
from airflow import DAG
|
from airflow import DAG
|
||||||
from airflow.providers.http.operators.http import SimpleHttpOperator
|
from airflow.providers.http.operators.http import SimpleHttpOperator
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from urllib.parse import urlencode
|
|
||||||
|
|
||||||
with DAG(
|
with DAG(
|
||||||
dag_id="clickhouse_list_tables",
|
dag_id="clickhouse_list_tables",
|
||||||
@@ -12,10 +11,10 @@ with DAG(
|
|||||||
|
|
||||||
list_tables = SimpleHttpOperator(
|
list_tables = SimpleHttpOperator(
|
||||||
task_id="list_tables",
|
task_id="list_tables",
|
||||||
http_conn_id="clickhouse_http", # Connection в Airflow
|
http_conn_id="clickhouse_http",
|
||||||
endpoint="/", # ClickHouse HTTP
|
endpoint="/",
|
||||||
method="POST",
|
method="POST",
|
||||||
data=urlencode({"query": "SHOW TABLES"}), # Нужно как x-www-form-urlencoded
|
data="SHOW TABLES",
|
||||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
headers={"Content-Type": "text/plain"},
|
||||||
log_response=True, # покажет результат в логах Airflow
|
log_response=True,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user