Postgres - how to connect?

I am trying to connect to postgres database from RoR. I have username
and password in database.yml, but when trying to connect, I get the
following error:

No such file or directory - /tmp/.s.PGSQL.5432

Why is it? I would also prefer to connect by TCP connection instead of
UNIX socket, how can I configure this?

Thanks in advance
Paweł Stawicki

On 22 Nov., 10:05, Pawel S. [email protected]
wrote:

I am trying to connect to postgres database from RoR. I have username
and password in database.yml, but when trying to connect, I get the
following error:

No such file or directory - /tmp/.s.PGSQL.5432

Why is it? I would also prefer to connect by TCP connection instead of
UNIX socket, how can I configure this?

I remember having the same problem, but I don’t remember
the details anymore. Anyway, here’s my current database.yml:

production:
adapter: postgresql
database: foo_production
username: postgres
password: secret
host: localhost
encoding: UTF8

Similar for test and development, no other settings.
(Especially, I think there was a “port” setting that needed to
be removed.)

HTH,
Stefan

Pawel S. wrote:

I am trying to connect to postgres database from RoR. I have username
and password in database.yml, but when trying to connect, I get the
following error:

No such file or directory - /tmp/.s.PGSQL.5432

Why is it? I would also prefer to connect by TCP connection instead of
UNIX socket, how can I configure this?

Check under ‘connections and authentication’ in data/postgresql.conf to
see if you’re listening on the connect ip-adresses (or listening on ip
at all).
You might also need to adapt data/pg_hba.conf to enable local access
with the account you’re using.

My database.yml looks like the one Stefan L. posted.

Piet.

Check under ‘connections and authentication’ in data/postgresql.conf to
see if you’re listening on the connect ip-adresses (or listening on ip
at all).

I am. I can connect by phpphadmin (web php tool) with user and password
without problems. But it seems to me that ruby tries to connect by
socket, not by TCP/IP, and I don’t like this.

Regards
Pawel S.

Ok, it worked, but now I got next error. I have table “Article”, and I
created model Article, but when I try to run test (just to test
connection), I get “Exception: RuntimeError: ERROR C42P01 Mrelation
“article” does not exist Fnamespace.c L221 RRangeVarGetRelid: DELETE
FROM article”

My table has name beginning with capital letter, but I think I doesn’t
matter, because when I had changed it, I still was getting the error.

Regards
Paweł Stawicki

Sorry, didn’t notice the first answer. I will try removing “port”.

Regards
Paweł Stawicki

Pawel S. wrote:

My table has name beginning with capital letter, but I think I doesn’t
matter, because when I had changed it, I still was getting the error.

I know the parent post is from a long time ago, but it turns out that
this is a bug in the rails postgresql adapter – it doesn’t support
table names with capital letters. There’s a ticket and patch here:

https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2418

If anyone could verify this patch, it would be much appreciated.

Thanks,
Scott