Load SQL dump in PostgreSQL without the password dependancy
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 开发者_StackOverflow社区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
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.
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
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
精彩评论