【发布时间】:2020-02-17 09:21:21
【问题描述】:
我正在尝试在新的作曲家环境中创建 DAG 以测试与 Postgres 数据库的连接。但我在气流中收到fe_sendauth: no password supplied 错误。我可以使用相同的 conn_id(无密码)在我们的旧作曲家环境中连接到这个数据库。
from airflow.operators.postgres_operator import PostgresOperator
from airflow.models import DAG, configuration
from airflow.utils.dates import days_ago
dag_params = {
'dag_id': 'test_postgres_yellow_connection',
'start_date': days_ago(1),
'schedule_interval': None
}
with DAG(**dag_params) as dag:
check_count = PostgresOperator(
task_id="check_count",
postgres_conn_id='postgres_yellow',
sql="""
select count(1) from db_name.table_name;
"""
)
check_count
这是气流日志:
[2020-02-17 06:01:17,142] {base_task_runner.py:101} INFO - Job 1403: Subtask check_count [2020-02-17 06:01:17,142] {postgres_operator.py:57} INFO - Executing:
[2020-02-17 06:01:17,143] {base_task_runner.py:101} INFO - Job 1403: Subtask check_count select count(1) from db_name.table_name;
[2020-02-17 06:01:17,143] {base_task_runner.py:101} INFO - Job 1403: Subtask check_count
[2020-02-17 06:01:17,165] {base_task_runner.py:101} INFO - Job 1403: Subtask check_count [2020-02-17 06:01:17,165] {base_hook.py:83} INFO - Using connection to: id: postgres_yellow. Host: hotname, Port: xxx, Schema: schema_name, Login: xxxx, Password: None, extra: {}
[2020-02-17 06:01:17,217] {models.py:1846} ERROR - fe_sendauth: no password supplie
Traceback (most recent call last)
File "/usr/local/lib/airflow/airflow/models.py", line 1714, in _run_raw_tas
result = task_copy.execute(context=context
File "/usr/local/lib/airflow/airflow/operators/postgres_operator.py", line 60, in execut
self.hook.run(self.sql, self.autocommit, parameters=self.parameters
File "/usr/local/lib/airflow/airflow/hooks/dbapi_hook.py", line 158, in ru
with closing(self.get_conn()) as conn
File "/usr/local/lib/airflow/airflow/hooks/postgres_hook.py", line 60, in get_con
self.conn = psycopg2.connect(**conn_args
File "/opt/python3.6/lib/python3.6/site-packages/psycopg2/__init__.py", line 126, in connec
conn = _connect(dsn, connection_factory=connection_factory, **kwasync
psycopg2.OperationalError: fe_sendauth: no password supplied
【问题讨论】:
标签: python postgresql airflow google-cloud-composer