Is there any possibility to dump the results of PostgreSQL commands directly on a txt/csv file ? i am talking about commands not queries, commands such as - SHOW ssl; - SHOW log_connections;
1 Answer
You can use the psql client for that.
\f ','
\a
\o <myoutputfile>
SHOW ssl;
\q
Or with command line options:
psql -t -A -F"," -c "SHOW ssl" > "<myoutputfile>"
2 Comments
Rahmouni Abdelhak
The 1st method works fine .. but i like the 2nd one better to script using batch .. but i couldn't force the login/connection credentials into the script .. any ideas @Thomas ?
Thomas Berger
You can provide much of the information, including password, as environment variables to psql: postgresql.org/docs/current/static/libpq-envars.html