【发布时间】:2020-06-24 04:04:42
【问题描述】:
我需要从 bash/expect 脚本执行以下 sql 查询 从 bash 脚本运行这些查询的首选方法是什么
# psql ambari -U ambari
Password for user ambari:
psql (9.2.24)
Type "help" for help.
ambari=>
ambari=>
ambari=>
ambari=> select
ambari-> sum(case when ulo = 1 then 1 else 0 end) as ulo_1,
ambari-> sum(case when ulo = 2 then 1 else 0 end) as ulo_2,
.
.
.
为了访问 PostgreSQL,我们这样做
psql ambari -U ambari
Password for user ambari:bigdata
当我们运行它时(/tmp/file 包括查询的 bach)
psql -U ambari -f /tmp/file ambari
我们得到
psql: FATAL: no pg_hba.conf entry for host "[local]", user "ambari", database "ambari", SSL off
【问题讨论】:
标签: sql bash postgresql psql