Re: Database connectivity using a unix shell - Mailing list pgsql-general

From Scott Marlowe
Subject Re: Database connectivity using a unix shell
Date
Msg-id 1151595193.13129.12.camel@state.g2switchworks.com
Whole thread Raw
In response to Database connectivity using a unix shell  ("Jasbinder Bali" <jsbali@gmail.com>)
Responses Re: Database connectivity using a unix shell
List pgsql-general
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`;

do a psql --help to get a list of options for psql.  -t means print only
the rows, no headers, and -q means to only display query output, no
messages or warnings.

pgsql-general by date:

Previous
From: Richard Broersma Jr
Date:
Subject: Re: Database connectivity using a unix shell
Next
From: "Jasbinder Bali"
Date:
Subject: Re: Database connectivity using a unix shell