Re: Database connectivity using a unix shell
От | elein |
---|---|
Тема | Re: Database connectivity using a unix shell |
Дата | |
Msg-id | 20060629183753.GR3541@varlena.com обсуждение исходный текст |
Ответ на | Re: Database connectivity using a unix shell (Scott Marlowe <smarlowe@g2switchworks.com>) |
Список | 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 >
В списке pgsql-general по дате отправления: