When I try to run
当我试图跑
manage.py test
a database password prompt shows.
显示数据库密码提示。
Previously, tests would run without me having to enter the db password manaually. I just updated my database to postgres 8.4. I assume it's some setting I'm forgetting.
以前,测试将在没有我必须手动输入db密码的情况下运行。我刚刚将我的数据库更新为postgres 8.4。我认为这是我忘记的一些设置。
How can I configure it to run tests without asking for the password?
如何配置它以在不询问密码的情况下运行测试?
Additional Info:
附加信息:
I created the database with the user 'postgres', but am accessing in django with the user, 'postgis'. I checked the permissions of these users, and they are the same.
我使用用户'postgres'创建了数据库,但是使用用户'postgis'访问django。我检查了这些用户的权限,它们是相同的。
When running the test the db and tables get created fine (no password requested). It's only when it installs 'Custom SQL' that the password is requested.
运行测试时,db和表可以正常创建(无需密码)。只有在安装“自定义SQL”时才会请求密码。
RESOLUTION
解析度
As Carl pointed out the ~/.pgpass file [*nix] and %APPDATA%\postgresql\pgpass.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile) [windows] allows you to configure databases so you don't need to enter a password each time.
正如Carl指出〜/ .pgpass文件[* nix]和%APPDATA%\ postgresql \ pgpass.conf(其中%APPDATA%引用用户配置文件中的Application Data子目录)[windows]允许您配置数据库,以便您每次都不需要输入密码。
See the postgres documentation: The Password File
请参阅postgres文档:密码文件
I checked my configuration and it looks like this file was/is auto-created. I updated my password file and now django tests run without the need to manually enter a password on each custom sql installation.
我检查了我的配置,看起来这个文件是/是自动创建的。我更新了我的密码文件,现在运行django测试,无需在每个自定义sql安装上手动输入密码。
2 个解决方案
#1
1
Django tests use a different database; your DATABASE_NAME setting with "_test" appended. My first guess would be that somewhere in your Postgres authentication config (either in pg_hba.conf or in a ~/.pgpass file), you are allowing access to DATABASE_NAME with no password, but you don't have the same config for DATABASE_NAME_test.
Django测试使用不同的数据库;添加了“_test”的DATABASE_NAME设置。我的第一个猜测是你的Postgres身份验证配置中的某个地方(在pg_hba.conf或〜/ .pgpass文件中),你允许访问没有密码的DATABASE_NAME,但你没有相同的DATABASE_NAME_test配置。
#2
0
I assume it's some setting I'm forgetting.
我认为这是我忘记的一些设置。
Not trying to make a fool out of you, but sometimes simple solutions are overlooked: Did you set the DATABASE_PASSWORD setting in your settings.py file?
不要试图愚弄你,但有时会忽略简单的解决方案:你是否在settings.py文件中设置了DATABASE_PASSWORD设置?
#1
1
Django tests use a different database; your DATABASE_NAME setting with "_test" appended. My first guess would be that somewhere in your Postgres authentication config (either in pg_hba.conf or in a ~/.pgpass file), you are allowing access to DATABASE_NAME with no password, but you don't have the same config for DATABASE_NAME_test.
Django测试使用不同的数据库;添加了“_test”的DATABASE_NAME设置。我的第一个猜测是你的Postgres身份验证配置中的某个地方(在pg_hba.conf或〜/ .pgpass文件中),你允许访问没有密码的DATABASE_NAME,但你没有相同的DATABASE_NAME_test配置。
#2
0
I assume it's some setting I'm forgetting.
我认为这是我忘记的一些设置。
Not trying to make a fool out of you, but sometimes simple solutions are overlooked: Did you set the DATABASE_PASSWORD setting in your settings.py file?
不要试图愚弄你,但有时会忽略简单的解决方案:你是否在settings.py文件中设置了DATABASE_PASSWORD设置?