views:

122

answers:

2

Hi,

I want my unit tests suite to load a SQL file in my database. I use a command like

"C:\Program Files\PostgreSQL\8.3\bin"\psql --host 127.0.0.1 --dbname unitTests --file C:\ZendStd\www\voo4\trunk\resources\sql\base_test_projectx.pg.sql --username postgres 2>&1

It run fine in command line, but need me to have a pgpass.conf Since I need to run unit tests suite on each of development PC, and on development server I want to simplify the deployment process. Is there any command line wich include password?

Thanks, Cédric

+1  A: 

Try adding something like to pg_hba.conf

local   all         postgres                             trust        

Of course, this allows anyone on the machine to connect as postgres, but it may do what you want.

EDIT:

You seem to be connecting to the localhost via TCP. You may need something like this instead:

host   all           postgres           127.0.0.1        trust

Again, I'm mostly guessing. I've never configured postgres quite this permissively.

ig0774
I don't understand why, but this does not work. I keep searching.
Cédric Girard
@Cedric: See my update. Maybe that works?
ig0774
Yes, but I need to add /32 to localhost ip adress (or the pg daemon don't start). Good solution if I can modifiy server configuration (for development purpose only, of course, not for real servers).
Cédric Girard
+1  A: 

You can use the PGPASSWORD environment variable, or the .pgpass file.

See http://www.postgresql.org/docs/8.4/static/libpq-envars.html and http://www.postgresql.org/docs/8.4/static/libpq-pgpass.html

Alison R.
I am looking how to set up the PGPASSWORD environment variable using exec(), it seems to be the easy way
Cédric Girard
As you have already read on one of the pages linked using PGAPASSWORD is not recommended.
Milen A. Radev
Yes, but I do this for a development PC, so security is not an issue here.
Cédric Girard
If you know you're always going to be on Windows, it's not a problem - Windows will isolate the environment from others users (and in fact other sessions for the same user)
Magnus Hagander