[GRASS-dev] [GRASS GIS] #2385: v.in.ogr doesn't use information from dblogin file about external PostgreSQL server

#2385: v.in.ogr doesn't use information from dblogin file about external
PostgreSQL server
-------------------------------------------------------+--------------------
Reporter: hemeybo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Database | Version: svn-releasebranch70
Keywords: v.in.ogr PostgreSQL db.login db.databases | Platform: Linux
      Cpu: x86-64 |
-------------------------------------------------------+--------------------
To import data from an external PostgreSQL server with v.in.ogr, I want to
use the dblogin file created with db.login with ip-address, user name and
password for the login on the external server.
Login on the server is working fine, since db.tables lists all tables on
the server.
Using db.databases with the location flag works also fine, listing all
available databases on the external server.
If I try to use v.in.ogr with the server login information in the dsn
string (with password written in plain text!!), everything is doing ok.
But since I don't want to write my password visible for everybody every
time I use the import function, I think, it should be possible to use
v.in.ogr with the login information of the dblogin file.

The error message, I recieve is the following:

"DBMI-PostgreSQL driver error:
Unable to 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"?

DBMI-PostgreSQL driver error:
Unable to 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"?

ERROR: Unable to list databases. Try to define correct connection settings
        by db.login."

This occurs to be the same error message as if I use db.databases without
the location flag.

For me, this somehow looks like the db.databases function is not working
properly together with the dblogin file.

The same problem occurs with the use of v.external

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2385&gt;
GRASS GIS <http://grass.osgeo.org>

#2385: v.in.ogr doesn't use information from dblogin file about external
PostgreSQL server
-------------------------------------------------------+--------------------
Reporter: hemeybo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Database | Version: svn-releasebranch70
Keywords: v.in.ogr PostgreSQL db.login db.databases | Platform: Linux
      Cpu: x86-64 |
-------------------------------------------------------+--------------------

Comment(by martinl):

This has been fixed in trunk, could you test it please? BTW, when using
default DB connection, you can leave datasource string empty, see
http://grass.osgeo.org/grass71/manuals/v.in.ogr.html#default-connection-
settings-as-datasource-%28postgresql-only%29

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2385#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2385: v.in.ogr doesn't use information from dblogin file about external
PostgreSQL server
-------------------------------------------------------+--------------------
Reporter: hemeybo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Database | Version: svn-releasebranch70
Keywords: v.in.ogr PostgreSQL db.login db.databases | Platform: Linux
      Cpu: x86-64 |
-------------------------------------------------------+--------------------

Comment(by hemeybo):

Unfortunately, there is not much improvement. The error moved on from
"Unable to list databases" to "Unable to open data source" with the
correct connection details. Here the new error message:

v.in.ogr dsn=PG: layer=bfn.nw_buk1000 output=nw_buk1001
ERROR 1: PQconnectdb failed.
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"?

ERROR: Unable to open data source
        <PG:dbname=host=134.110.32.101,dbname=gis>

It seems like the dsn is not created properly - the first "dbname=" is
wrong, in my opinion.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2385#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2385: v.in.ogr doesn't use information from dblogin file about external
PostgreSQL server
-------------------------------------------------------+--------------------
Reporter: hemeybo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Database | Version: svn-releasebranch70
Keywords: v.in.ogr PostgreSQL db.login db.databases | Platform: Linux
      Cpu: x86-64 |
-------------------------------------------------------+--------------------

Comment(by martinl):

Replying to [comment:2 hemeybo]:

> ERROR: Unable to open data source
> <PG:dbname=host=134.110.32.101,dbname=gis>
>
> It seems like the dsn is not created properly - the first "dbname=" is
wrong, in my opinion.

please post here the commands in which you set up the connection settings
(`db.connect` and `db.login`).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2385#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2385: v.in.ogr doesn't use information from dblogin file about external
PostgreSQL server
-------------------------------------------------------+--------------------
Reporter: hemeybo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Database | Version: svn-releasebranch70
Keywords: v.in.ogr PostgreSQL db.login db.databases | Platform: Linux
      Cpu: x86-64 |
-------------------------------------------------------+--------------------

Comment(by hemeybo):

here the commands for the connection settings:

db.connect driver=pg database="host=134.110.32.101,dbname=gis"
db.login user=''username'' pass=''password''

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2385#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>