Determine if a user and database are available
От | Jeffrey Walton |
---|---|
Тема | Determine if a user and database are available |
Дата | |
Msg-id | CAH8yC8=fbU-DWSNso7qKDSNCj52hTop8ENKxF7_4a=hjY-nn6w@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Determine if a user and database are available
Re: Determine if a user and database are available Re: Determine if a user and database are available |
Список | pgsql-general |
Hi Everyone, I have another beginner question. I am trying to use pg_isready to determine if a database and user are present. The program seems to always succeed, even when I delete the user or the database. This baffles me from the man page. I guess this explains the behavior I am seeing. NOTES It is not necessary to supply correct user name, password, or database name values to obtain the server status; however, if incorrect values are provided, the server will log a failed connection attempt. A typical usage is shown below, where variables are parsed from a config file. password=$(grep 'DD_DB_Rpass' dojoConfig.yml | awk '{ print $2 }') hostname=$(grep 'DD_DB_Host' dojoConfig.yml | awk '{ print $2 }') database=$(grep 'DD_DB_Name' dojoConfig.yml | awk '{ print $2 }') username=$(grep 'DD_DB_Ruser' dojoConfig.yml | awk '{ print $2 }') PGPASSWORD=${password} pg_isready \ -h "${hostname}" -U "${username}" -d "${database}" Given the NOTES in the man page, how do we determine if a user and database are present using the shell? Is there another utility we should be using? Thanks in advance, Jeff
В списке pgsql-general по дате отправления: