Re: Database connectivity using a unix shell

From: "Jasbinder Bali" <jsbali(at)gmail(dot)com>
To: "Scott Marlowe" <smarlowe(at)g2switchworks(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Database connectivity using a unix shell
Date: 2006-06-29 16:29:24
Message-ID: a47902760606290929k2ba32fd3y70b33e9f8a4e6951@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

isn't my normal bash script different from psql.
In a bash script how wud u specify the db parameters

On 6/29/06, Scott Marlowe <smarlowe(at)g2switchworks(dot)com> wrote:
>
> On Thu, 2006-06-29 at 11:08, Jasbinder Bali wrote:
> >
> > On 6/29/06, Scott Marlowe <smarlowe(at)g2switchworks(dot)com> wrote:
> > On Thu, 2006-06-29 at 10:24, Jasbinder Bali wrote:
> > > > Hi
> > > > I need to connect to the postgres database using my unix shell.
> > > > How should i go about it?
> > > > Is libpq going to be helpful here?
> >
> > > There is a shell interface for postgresql called psql.
> >
> > > If you have postgresql installed on a box, then the psql interface
> > > should be there.
> >
> > > If you need to access postgresql from within a bash script, you can
> > > do So with a construct kinda like this:
> >
> > > query="select * from sometable";
> > > a=`echo $query|psql -tq dbname`;
>
> > in my bash script where and how do i specify the database connection
> > parameters
>
> In psql you can use -U to specify your username. for password info, you
> need to use a .pgpass file (i.e. no passwords on the command line).
>
> http://www.postgresql.org/docs/8.1/interactive/libpq-pgpass.html
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2006-06-29 16:32:56 Re: Fixed length datatypes. WAS [GENERAL] UUID's as
Previous Message Scott Marlowe 2006-06-29 16:18:12 Re: Database connectivity using a unix shell