我希望我的单元测试套件在数据库中加载一个SQL文件。我使用的命令如下
"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它在命令行中运行良好,但我需要有一个pgpass.conf,因为我需要在每台开发PC上运行单元测试套件,而在开发服务器上,我希望简化部署过程。是否有包含密码的命令行?
谢谢,Cédric
发布于 2013-03-13 10:17:24
您应该运行包含以下内容的bash脚本文件"run_sql_commands.sh“:
export PGHOST=localhost
export PGPORT=5432
export PGDATABASE=postgres
export PGPASSWORD=postgres
export PGUSER=postgres
psql -f file_with_sql_commands.sql发布于 2010-05-13 00:33:17
尝试添加类似于pg_hba.conf的内容
local all postgres trust 当然,这允许机器上的任何人以postgres身份连接,但它可能会做您想做的事情。
编辑:
您似乎正在通过TCP连接到本地主机。您可能需要这样的代码:
host all postgres 127.0.0.1 trust再说一次,我主要是在猜测。我从来没有对postgres进行过如此宽松的配置。
发布于 2010-05-13 00:35:44
可以使用PGPASSWORD环境变量或.pgpass文件。
请参阅http://www.postgresql.org/docs/8.4/static/libpq-envars.html和http://www.postgresql.org/docs/8.4/static/libpq-pgpass.html
https://stackoverflow.com/questions/2820670
复制相似问题