[GRASS-user] connect to postgreSQL

Glynn Clements glynn at gclements.plus.com
Sat Oct 4 21:59:32 EDT 2008


Stanislav Bek wrote:

> I have problem to connect to postgreSQL server from grass.
> 
> GRASS 6.3.0 (opava):~ > psql -l
>         List of databases
>    Name    |  Owner   | Encoding 
> -----------+----------+----------
>  gis1      | bekas    | UTF8
>  postgres  | postgres | UTF8
>  template0 | postgres | UTF8
>  template1 | postgres | UTF8
> (4 rows)
> 
> GRASS 6.3.0 (opava):~ > db.connect driver=pg database=gis1 
> 
> GRASS 6.3.0 (opava):~ > db.test test=test1
> create table grass_test1 (i1 integer, d1 double precision, c1 varchar(20))
> DBMI-Postgres driver error:
> Cannot connect to Postgres: could not connect to server: No such file or directory
> 	Is the server running locally and accepting
> 	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Try:

	db.connect driver=pg database="host=localhost,dbname=gis1"

to connect using TCP.

Also, "netstat -ax" will list active Unix-domain sockets. If
postmaster is accepting local (Unix-domain) connections, its socket
will be listed there. E.g. I have:

unix  2      [ ACC ]     STREAM     LISTENING     3442     /tmp/.s.PGSQL.5432

If it's listening on a Unix-domain socket, check that you have the
necessary permissions on both the socket and its parent directories.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list