Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to call PostgreSQL function from windows command line. the Postgres DB located on a linux VM. I can run the command line but been prompted for password. how can I work around it? Since the DB is on different VM, i cant modify the pgpass.conf file - it doesn't exist. any other easy way?

Thanks.

share|improve this question
add comment

1 Answer 1

You can run psql on Windows to run a SELECT query that calls the function. To prevent psql from prompting for a password, you can set the password in the PGPASSWORD environment variable.

Optionally, for something which is generally considered somewhat more secure, you could use the pgpass file, which on Windows is located in %APPDATA%\postgresql\pgpass.conf and store the password in there. More details on that can be found here: http://www.postgresql.org/docs/9.3/static/libpq-pgpass.html

share|improve this answer
    
The Environment Variable works great. –  user3716685 Jun 9 at 17:41
    
Cool. Since it appears to have solved your issue, please accept my answer. –  Ken Hampson Jun 10 at 2:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.