Search Postgresql Archives

Determine if a user and database are available

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux