Sorry I didn't mention I am running the script as \i [sqlfile]
More often than not, I do a \conninfo first to confirm which database I am connecting to just to be safe. Wanting to redirect that information to the output file is for reference in case there's an issue and I needed to prove that I am indeed connected to the right database/host based on \conninfo.
At the moment, using script [outfile] and \o | tee [outfile]. The latter produces a cleaner output. Will search if there is a SQL that will give a similar output to \conninfo or do you happen to have one :-)
On Thu, Feb 8, 2024 at 1:52 AM Erik Wienhold <ewie@ewie.name> wrote:
On 2024-02-07 11:39 +0100, Edwin UY wrote: > Thanks Erik, the \o | tee outfile does the trick. Never thought of that. > It appears to exclude the output from psql I think like \conninfo or > \encoding.
From the docs:
'“Query results” includes all tables, command responses, and notices obtained from the database server, as well as output of various backslash commands that query the database (such as \d); but not error messages.'