psql: Is it possible to run a query from a *sql file?

From: Ennio-Sr <nasr(dot)laili(at)tin(dot)it>
To: pgsql-novice(at)postgresql(dot)org
Subject: psql: Is it possible to run a query from a *sql file?
Date: 2005-05-01 16:32:03
Message-ID: 20050501163203.GA2497@deby.ei.hnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

[Running PG 7.4.7-5 on GNU-Linux Debian Sarge]

Hi all,
I'm wondering if it is possible to run a query from a .sql file, so as
to automate certain searches from console.
I've been unsuccessfully trying something like this simple one:

------------
\! echo "insert key: ";read key; export $key;
SELECT autore, titolo, editore FROM bibl WHERE autore like '%[$key]%'
------------

Most likely the answer is 'no', as psql is an 'interactive'
application.
There seems to be no communication between the shell (where you digit
the key) and psql: the key vanishes somewhere ... ;(

Regards,
Ennio

BTW: Somebody knows where does pgaccess store its queries?

--
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo. \\?//
Fa' qualche cosa di cui non sei capace!" (diceva Henry Miller) ] (°|°)
[Why use Win$ozz (I say) if ... "even a fool can do that. )=(
Do something you aren't good at!" (as Henry Miller used to say) ]

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2005-05-01 17:24:29 Re: psql: Is it possible to run a query from a *sql file?
Previous Message tövis 2005-05-01 14:14:08 CONSTRAINT ... FOREIGN KEY