From: | elein <elein(at)varlena(dot)com> |
---|---|
To: | Scott Marlowe <smarlowe(at)g2switchworks(dot)com> |
Cc: | Jasbinder Bali <jsbali(at)gmail(dot)com>, pgsql general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Database connectivity using a unix shell |
Date: | 2006-06-29 18:37:53 |
Message-ID: | 20060629183753.GR3541@varlena.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
This is a variation of the same:
a=`psql -U postgres -h my.host.dom -Atc "select col1 from sometable where col2=6" dbname`
echo $a
Note that the -U and -h can specify the user name and hostname if necessary.
-A gets the data unaligned
-t gets the data without the decorations
-c "query" specifies the query to run
dbname is required if it is not the default.
Also see psql --help
elein
On Thu, Jun 29, 2006 at 11:40:49AM -0500, Scott Marlowe wrote:
> On Thu, 2006-06-29 at 11:29, Jasbinder Bali wrote:
> > isn't my normal bash script different from psql.
> > In a bash script how wud u specify the db parameters
>
> Look at how I'm doing it here:
>
> > > > query="select * from sometable";
> > > > a=`echo $query|psql -tq dbname`;
>
> Note that I'm calling psql from within a bash script. So, the connection
> params are the same as for psql, cause that's what I'm using.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
From | Date | Subject | |
---|---|---|---|
Next Message | Jasbinder Bali | 2006-06-29 19:53:00 | Re: Database connectivity using a unix shell |
Previous Message | Chris Browne | 2006-06-29 18:30:34 | Re: Database connectivity using a unix shell |