![](/img/trans.png)
[英]hasura database connection failing with error : password authentication failed for user postgres
[英]@ in password and Airflow postgres connection is failing
在我的 Postgres 密码中,airflow.cfg 中有一个 @.Something like dba@123 我已将我的数据库密码指定为
#sql_alchemy_conn = postgresql+psycopg2://user:dba@123@postgresserver.com:5432/airflow
抛出错误为
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "123@postgresserver.com" to address: Name or service not known
我试图将密码指定为 postgresql 的参数
sql_alchemy_conn = postgresql+psycopg2://user:dba@123@postgresserver.com:5432/airflow?password=dba@123
但没有工作。
谁能帮忙
也许这可以帮助您将数据库属性设置为环境变量,然后您可以通过 function 获取它们,这样您就不会收到错误。
# def db_props():
# db_config = {
# 'host': os.environ["_HOST"],
# 'port': os.environ["_PORT"],
# 'db': os.environ["_DATABASE"],
# 'username': os.environ["_USERNAME"],
# 'password': os.environ["_PASSWORD"]
# }
# return db_config
and later in code, you can do this while making a connection
db_config = db_props()
server = db_config['host']
port = db_config['port']
database = db_config['db']
username = db_config["username"]
password = db_config['password']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.