I am trying to run a command in psql that looks like
psql -h localhost -U username postgres -c
"select * from pg_stat_database LIMIT(1);"
&& echo -e "\e[0;32mPostgres connection - OK\e[0m"
|| echo -e "\e[0;31mCannot connect to Postgres\e[0m";
there is a different username but for security purposes I have taken it out. I keep on getting this error message and I'm not sure why. If anyone can point me in the right direction or has any experience with this please answer or comment below!
ERROR: syntax error at or near "psql"
LINE 1: psql -h localhost -U datadog postgres -c
^
SJ=#
Solution of the problem
can you try this using the long term keyword,
type your hostname, username and your password correctly
psql --host=localhost --username=username --command=command --password
I am using Windows as an operating system, I downloaded and tested the latest version using the following command:
.\psql.exe --host=localhost --username=username --password
.\psql.exe --host=rajje.db.elephantsql.com --username=snvxasza --password
I have created a free online database for testing at ElephantSQL
The full documentation can be found here
Aucun commentaire:
Enregistrer un commentaire