If I have a postgresql connection string:
export my_conn='postgresql://vadmin:Gimme5br@platform-prod.clfk51eo.us-west-2.rds.amazonaws.com/prod'
how can I test this connection? I tried:
pqsl "$my_conn"
and it just hangs
If I have a postgresql connection string:
export my_conn='postgresql://vadmin:Gimme5br@platform-prod.clfk51eo.us-west-2.rds.amazonaws.com/prod'
how can I test this connection? I tried:
pqsl "$my_conn"
and it just hangs
The best tool for the purpose is pg_isready.
Simply run
pg_isready -d "$my_conn"
and check the return code.
Run this instead:
psql "$my_conn" -c "SELECT 1"
This would try to execute a simple query that always should return a one-row result and then exit. Also you could check the exit code of the operation by calling:
echo $?
Anything different than 0 would mean some error.