redirecting query statement and output to a marked up file, using psql

From: Wim Bertels <wim(dot)bertels(at)khleuven(dot)be>
To: pgsql-general(at)postgresql(dot)org
Subject: redirecting query statement and output to a marked up file, using psql
Date: 2011-02-02 14:41:03
Message-ID: 1296657663.2171.9.camel@zwerfkat
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hallo,

goal:
to write the input and query results to different files in 1 script

context example:
1 sql script demo.sql
"
--init messaging
\set client_min_messages warning
\set log_error_verbosity terse

--user1
SET SESSION AUTHORIZATION user1;
\pset format html
\o report/test_user1.html
\i structure/test_user1.sql

--user2
SET SESSION AUTHORIZATION user2;
\pset format latex
\echo ECHO queries
\o report/test_user2.tex
\i structure/test_user2.sql
"

This doenst seem to work,
as the ECHO queries output isnt written to the file (test_user2.tex)

The only work around i found so far,
is using redirection.
starting for example
> psql -L out.txt # only txt markup
or
> psql > out.txt
But then if have to postprocess the out.txt file, dividing it into
several different files, and the format/markup doenst work so nice any
more.

Suggestions?

tnx,
Wim

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-02-02 14:41:06 Re: Importing/Appending to Existing Table
Previous Message Rich Shepard 2011-02-02 14:29:54 Re: Importing/Appending to Existing Table