Re: scripting & psql issues
От | Paul Thomas |
---|---|
Тема | Re: scripting & psql issues |
Дата | |
Msg-id | 20040818131851.A30421@bacon обсуждение исходный текст |
Ответ на | scripting & psql issues (Dino Vliet <dino_vliet@yahoo.com>) |
Список | pgsql-general |
On 18/08/2004 12:57 Dino Vliet wrote: > Hi folks, > probably this is a question you've heard so many times > but I wasn't able to find a solution to it. > > I'm using a shell script to create a textfile for me. > It looks like > #!/usr/local/bin/bash > psql -c "select foo from bar;" -d database1 -t > psql -c "\q" -d database1 > exit 0 > > The second psql -c "\q" command is used to logout from > the first database. But I'm not sure whether this is > correct. Not needed. The 1st command will exit by itself (man psql). > How do I mix these sql and psql meta-commands > otherwise if I want to be able to use myscript > > output.txt to get the output from this select > statement in the file output.txt. I'm planning to > write a cron job for it too. You could use $HOME/.psqlrc. > > Another issues is passwords. Normally when I log onto > database1, I have to issue a password because only the > superuser is trusted in the pg_hba.conf file. However > for scripts that I want to be able to run in the > background like this one, I had to add an entry to the > pg_hba.conf file to trust this user also. But as from > security point of view, I'm wondering if this is the > best way to achieve it. You could use $HOME/.pgpass. -- Paul Thomas +------------------------------+---------------------------------------------+ | Thomas Micro Systems Limited | Software Solutions for Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +------------------------------+---------------------------------------------+
В списке pgsql-general по дате отправления: