[Rails] a remote database issue

Kim kim at tinker.com
Tue Mar 1 16:11:57 GMT 2005


On Mar 1, 2005, at 4:22 AM, Dick Davies wrote:

> * Robby Russell <robby at planetargon.com> [0211 22:11]:
>> I am trying to connect to a remote postgresql database and am having 
>> no
>> luck when I run rake.
>>
>> For example:
>>
>>  rake outputs:
>>
>>> pg_dump: [archiver (db)] connection to database "dbname" failed: 
>>> could
>>> not connect to server: No such file or directory
>
> The :clone_structure_to_test can't work remotely, since it sets up 
> pg_dump is set up
> to talk to a local socket (another consequence of this is that you 
> need 'trust'
> access to the local domain socket when running the unit tests, which 
> makes Baby
> Jesus cry if you don't want your Rails coders to be able to login as 
> the postgres
> superuser).
>

I also have a problem with this and I am looking into changing the way 
the test database
is cloned so that it doesn't use dropdb and createdb.  I am also 
looking into adding the
capability of having the test setup do its cloning as a database user 
that owns the
database and has full rights to it and then logging off before running 
the tests as
the user I have the web site log in as which has much fewer permissions.

> I tried fixing this last week, but it's complicated by the fact that
> pg_dump doesn't take a password.
>
> One fix (I havent' tried yet) is to use a ~/.pgpass file to code the 
> database settings.
> It's not ideal, but then you can:
>
> a) secure the db properly
> b) run the tests against a remote db
>

There is an undocumented environment variable you can set.  If you set 
PQpass to
your password, it will not prompt for one.

> It's also worth mentioning that the rails db user needs 'create 
> database'
> privilege (for the dropdb/createdb operation in the 
> :purge_test_database task to work.
>
> Personally I'd like to see us get away from pg_dump and find another 
> way to
> pull the schema from development and drop everything from the test db
> (rather than dropdb/createdb).
> I'm beginning to think this should be done in the adapter..
>
>

I am looking into this sort of thing.  However, due to my other 
projects, it may
be a while before I get something that works.  Do you know if anyone 
else is working
on this so I don't duplicate someone else's effort?

>>>        Is the server running locally and accepting
>>>        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
>>> dropdb: could not connect to database template1: could not connect to
>
>>> development:
>>>  adapter: postgresql
>>>  database: dbname
>>>  host: 192.168.1.25
>>>  port: 5432
>>>  username: webuser
>>>  password: password
>>
>> Why is it trying to use the sockets when I need it to connect 
>> remotely?
>> It almost seems like it is ignoring the host:
>

Kim



More information about the Rails mailing list