From: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general@lists.postgresql.org
Subject: Formating psql query output
Date: Mon, 19 Jul 2021 10:33:02 -0700 (PDT)
Message-ID: <alpine.LNX.2.20.2107191021180.13362@salmo.appl-ecosys.com> (raw)
Until I finish building the python/tkinter/psycopg2 front end to my business
tracking tool I continue to work using the psql shell.'
I have a working .sql script that reports my contacts between two dates; the
script returns more columns than I want included in the report. I want to
pipe the output through an awk script to extract, in order, the columns I
need. I'm stuck at the point of defining options to psql.
The current command line is:
psql -d bustrac -f prospecting_log.sql -o contacts.txt --csv
However, using the --csv output conversion makes separate fields from a
varchar column that can contain commas with the text contents.
Without --csv I get normal psql output with column headings and separator
lines such as these:
person_nbr | act_date | act_type | notes | person_nbr | lname | fname | org_nbr | org_nbr | org_name
------------+------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------------------+------------+---------+---------+----------------------
Is there an option that will retain the '|' separator but exclude the
headings? Reading the psql document page I don't see such an option.
TIA,
Rich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: rshepard@appl-ecosys.com
Subject: Re: Formating psql query output
In-Reply-To: <alpine.LNX.2.20.2107191021180.13362@salmo.appl-ecosys.com>
References: <alpine.LNX.2.20.2107191021180.13362@salmo.appl-ecosys.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox