1

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

Cédric Girard
  • 3,358
  • 7
  • 37
  • 52

3 Answers3

2

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
  • 39,669
  • 3
  • 55
  • 57
  • I don't understand why, but this does not work. I keep searching. – Cédric Girard May 12 '10 at 16:52
  • 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 May 13 '10 at 08:38
1

You should run a bash script file "run_sql_commands.sh" with this content:

export PGHOST=localhost             
export PGPORT=5432
export PGDATABASE=postgres
export PGPASSWORD=postgres
export PGUSER=postgres

psql -f file_with_sql_commands.sql
ggv
  • 46
  • 1
  • 2
1

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.
  • 4,204
  • 28
  • 33