我正在尝试在新的作曲家环境中创建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
答案 0 :(得分:0)
可能您的旧环境用户在您的Protected Overrides Sub OnLeave(e As EventArgs)
'Remember the current selection.
selectionStartTemp = SelectionStart
selectionLengthTemp = SelectionLength
MyBase.OnLeave(e) 'this has to go last because it modifies the SelectionStart...
End Sub
文件中被设置为可信用户。如您在 trust 身份验证方法中看到的here:
无条件允许连接。这种方法允许任何 可以连接到PostgreSQL数据库服务器以任何方式登录 他们希望的PostgreSQL用户,不需要密码或任何其他信息 其他身份验证。有关详细信息,请参见第19.3.1节。
请告诉我是否对您有帮助