Fwd: psql in bash scrpts, is possible ?

From: Mariateresa L <mariateresa(dot)ll(at)bresciaonline(dot)it>
To: pgsql-novice(at)postgresql(dot)org
Subject: Fwd: psql in bash scrpts, is possible ?
Date: 2010-05-31 21:02:37
Message-ID: 4C0423ED.4050506@bresciaonline.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

-------- Messaggio originale --------
From: - Mon May 31 22:53:06 2010
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00800000
X-Mozilla-Keys:
Message-ID: <4C0421A8(dot)2090801(at)bresciaonline(dot)it>
Disposition-Notification-To: Mariateresa L <mariateresa(dot)ll(at)bresciaonline(dot)it>
Date: Mon, 31 May 2010 22:52:56 +0200
From: Mariateresa L <mariateresa(dot)ll(at)bresciaonline(dot)it>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.1.9)
Gecko/20100317 Thunderbird/3.0.4
MIME-Version: 1.0
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] psql in bash scrpts, is possible ?
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hello everyone,

I'm building a small newspaper informations aggregator around postgresql
8.3 and Ubuntu 9.10.
Starting from a previous experience on Oracle DB, I've built and tested
a bunch of functions, triggers, SQL scripts etc... that work flawlessly
(almost !) when I submit them by hand in psql; now I want to pack
everything in a nice shell script, with proper error control, automated
file shuffling, predefined queries in text files and so on, but I
cannot convince psql that the SQL commands (select, insert or copy...)
it has to handle come from a file.
I can submit ("\i filename" or "psql --file filename") files that
contains commands, eg starting with "\" but psql does not understand the
same sintax if tne file contains a simple "SELECT * FROM tablex".

Am I uber-newbie or is this a known limitation of psql ? And, in this
case, there is something to overcome this limit and afford my non-techie
user to launch a simple command to print her data or to bulk update tables ?

P.S. Initially I discarded the use of procedural languages (C or ...)
for a quick and simpler solution !

Thanks in advance

Fabio, from North Italy

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Mariateresa L 2010-05-31 21:05:38 sql files in psql ?
Previous Message Mariateresa L 2010-05-31 20:52:56 psql in bash scrpts, is possible ?