Re: How to output psql to file AND screen/console

Поиск
Список
Период
Сортировка
От Erik Wienhold
Тема Re: How to output psql to file AND screen/console
Дата
Msg-id xzetz4auxundsjp5ad4cfbotwrgijinewawwwzfp3avl2cnzed@ndcocq6j5soo
обсуждение исходный текст
Ответ на Re: How to output psql to file AND screen/console  (Edwin UY <edwin.uy@gmail.com>)
Ответы Re: How to output psql to file AND screen/console
Список pgsql-admin
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.'

https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-META-COMMAND-OUT

\conninfo and \encoding don't access the server, hence their outputs are
not query results.

> Is there a way to get those to show in the outfile too? This is the same
> for when not using tee as well.

Your first mail says that you want to run a script.  I don't see why
that shouldn't work:

    $ psql -f myscript.sql | tee outfile

In that case stdout will be piped to tee and that will also cover
output of commands such as \conninfo.

But I'm out of ideas for psql's interactive mode.

-- 
Erik



В списке pgsql-admin по дате отправления:

Предыдущее
От: Edwin UY
Дата:
Сообщение: Re: How to output psql to file AND screen/console
Следующее
От: Edwin UY
Дата:
Сообщение: Re: How to output psql to file AND screen/console