0

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 1

1

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>"
Sign up to request clarification or add additional context in comments.

2 Comments

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 ?
You can provide much of the information, including password, as environment variables to psql: postgresql.org/docs/current/static/libpq-envars.html

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.