Re: How to query pgsql from a BASH script ?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: How to query pgsql from a BASH script ?
Дата
Msg-id 20050404145605.GA9422@svana.org
обсуждение исходный текст
Ответ на Re: How to query pgsql from a BASH script ?  (Pavel Stehule <stehule@kix.fsv.cvut.cz>)
Список pgsql-general
On Sun, Apr 03, 2005 at 11:17:41PM +0200, Pavel Stehule wrote:
> test=# select * from foo;
>  a  | b
> ----+----
>  10 | 10
>  10 | 20
>
> pgbash> retval=`select a,b from foo;`
> pgbash> echo $retval
> a | b ----+---- 10 | 10 10 | 20 (2 rows)

The way I usually do it in scripts is:

psql '-F<tab>' -A -t -c "query"

If there's only one field output you can drop the -F.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Вложения

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

Предыдущее
От: Janning Vygen
Дата:
Сообщение: invalid input syntax for type bytea
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: [HACKERS] plPHP in core?