[GRASS-dev] G70: Link to PG database issue (wxGUI)

Hi,

I tried to connect to a PostGIS database but in the wxGUI tool (File
-> Link external data -> Link external vector data) the "PostgreSQL"
selector offers only a greyed out filed (editable for SQLite etc).

I had recompiled my installation with PG support:

db.connect help
...
Parameters:
    driver Name of database driver
             options: ogr,pg,sqlite,dbf <<-- ok
             default: sqlite

so I don't understand why the wxGUI link tool silently suppressed
PostgreSQL here (it could tell me at least why :slight_smile:

Any suggestions?

thanks
Markus

Hi,

2014-05-24 0:36 GMT+02:00 Markus Neteler <neteler@osgeo.org>:

[...]

so I don't understand why the wxGUI link tool silently suppressed
PostgreSQL here (it could tell me at least why :slight_smile:

do you have any PG database accessible?

db.database dri=pg

Martin

--
Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa

On Sat, May 24, 2014 at 9:28 AM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2014-05-24 0:36 GMT+02:00 Markus Neteler <neteler@osgeo.org>:

[...]

so I don't understand why the wxGUI link tool silently suppressed
PostgreSQL here (it could tell me at least why :slight_smile:

do you have any PG database accessible?

Aha...

db.databases driver=pg
DBMI-PostgreSQL driver error:
Unable to connect to Postgres:
FATAL: role "neteler" does not exist

OK, sure - the PG user name is different here. Would be cool to pop up
this error message in the wxGUI somehow to get on the right track
(maybe when the user attempts to select PG in the dropdown list?).

My scope is to fetch some points from PostGIS with v.external while
keeping the DB settings using SQLite.

Markus

Hi,

2014-05-24 10:06 GMT+02:00 Markus Neteler <neteler@osgeo.org>:

[...]

OK, sure - the PG user name is different here. Would be cool to pop up
this error message in the wxGUI somehow to get on the right track
(maybe when the user attempts to select PG in the dropdown list?).

done in r60461 (wxGUI error), I have also added note about db.login
r60462 (trunk only). Ideally the wxGUI dialog should contain
user/passwd widget to enter the values directly without need to launch
db.login explicitly. Please feel free to fill enhancement ticket.
Martin

--
Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa

2014-05-24 22:40 GMT+02:00 Martin Landa <landa.martin@gmail.com>:

done in r60461 (wxGUI error), I have also added note about db.login
r60462 (trunk only). Ideally the wxGUI dialog should contain
user/passwd widget to enter the values directly without need to launch
db.login explicitly. Please feel free to fill enhancement ticket.

related - in r60465-6 I fixed `db.databases` to understand settings
from `db.login`.

$ db.databases dri=pg
DBMI-PostgreSQL driver error:
Unable to connect to Postgres:
fe_sendauth: no password supplied

DBMI-PostgreSQL driver error:
Unable to connect to Postgres:
fe_sendauth: no password supplied

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

$ db.login dri=pg user=martin pass=xxx

$ db.databases dri=pg
template1
template0
postgres
...

Martin

--
Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa

Hi Martin,

On Sat, May 24, 2014 at 11:12 PM, Martin Landa <landa.martin@gmail.com> wrote:

2014-05-24 22:40 GMT+02:00 Martin Landa <landa.martin@gmail.com>:

done in r60461 (wxGUI error), I have also added note about db.login
r60462 (trunk only). Ideally the wxGUI dialog should contain
user/passwd widget to enter the values directly without need to launch
db.login explicitly. Please feel free to fill enhancement ticket.

ok, perhaps once the rest is there.

related - in r60465-6 I fixed `db.databases` to understand settings
from `db.login`.

$ db.databases dri=pg
DBMI-PostgreSQL driver error:
Unable to connect to Postgres:
fe_sendauth: no password supplied

DBMI-PostgreSQL driver error:
Unable to connect to Postgres:
fe_sendauth: no password supplied

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

Tested and works in the wxGUI - the message pops up. Thanks.

BTW, partially related:
http://trac.osgeo.org/grass/ticket/1951

$ db.login dri=pg user=martin pass=xxx

Sidenote:
I wonder how to avoid to specify the pw on command line. In r39879 the
interactive query was removed.
Indeed, I would even prefer to scramble the pw and **** when typing it
into the GUI window which would be done with

http://wxpython.org/Phoenix/docs/html/TextCtrl.html
TE_PASSWORD: The text will be echoed as asterisks.

No idea if a flag could be added to enable this (perhaps a new
G_define_option() for password strings?

$ db.databases dri=pg
template1
template0
postgres
...

While this is now working also here, in terms of the original issue I
wonder if it is needed to switch the DB settings for the mapset when
"only" trying to link to one PostGIS vector map (so a kind of mixed
use).

Markus

Hi,

2014-05-25 12:24 GMT+02:00 Markus Neteler <neteler@osgeo.org>:

[...]

While this is now working also here, in terms of the original issue I
wonder if it is needed to switch the DB settings for the mapset when
"only" trying to link to one PostGIS vector map (so a kind of mixed
use).

running `db.login` doesn't mean that you switch DB settings. It just
allows you to defined user/password for given driver, nothing else.

$ db.connect -p
driver: sqlite
database: /opt/grassdata/gis1-sjtsk/g6/sqlite/sqlite.db

$ db.databases dri=pg
DBMI-PostgreSQL driver error:
Unable to connect to Postgres:
fe_sendauth: no password supplied

DBMI-PostgreSQL driver error:
Unable to connect to Postgres:
fe_sendauth: no password supplied

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

OK, something is missing.

$ db.login dri=pg user=xxx passwd=yyy

$ db.databases dri=pg
template1
template0

Default DB settings untouched...

$ db.connect -p
driver: sqlite
database: /opt/grassdata/gis1-sjtsk/g6/sqlite/sqlite.db
schema:
group:

Martin

--
Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa

On Sun, May 25, 2014 at 7:57 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2014-05-25 12:24 GMT+02:00 Markus Neteler <neteler@osgeo.org>:

[...]

While this is now working also here, in terms of the original issue I
wonder if it is needed to switch the DB settings for the mapset when
"only" trying to link to one PostGIS vector map (so a kind of mixed
use).

running `db.login` doesn't mean that you switch DB settings. It just
allows you to defined user/password for given driver, nothing else.

ok, good! I got confused by the actual manual of db.login:

"DESCRIPTION

db.login sets the user name and optionally also a password for the
connection to the selected database through the DB driver.
"

This should be expanded (good wording welcome).

Markus