[GRASS-user] Finding why postgres database cannot be opened

Moritz Lennert mlennert at club.worldonline.be
Wed Nov 7 11:18:16 PST 2018


Hi Rich,

On 7/11/18 19:55, Rich Shepard wrote:
>    Grass seems to recognize the postgres data base and that I'm logged 
> in to
> it:
> 
>> db.connect -p
> driver: pg
> database: 
> /home/rshepard/data/grassdata/willamette_basin/willamette-river-hg
> 
>> db.login driver=pg database=willamette-river-hg --o
> WARNING: DB connection <pg/willamette-river-hg> already exists and will be
>           overwritten
> 
>    If the mapset recognizes that geometry attributes are stored in the
> postgres database, and user me has access to these attribute tables, what
> might be the cause of this error (seen with multiple maps):
> 
>> db.columns table=fishes
> DBMI-PostgreSQL driver error:
> Connection failed.
> FATAL:  database 
> "/home/rshepard/data/grassdata/willamette_basin/willamette-river" does 
> not exist
> 
> WARNING: Unable to open database
>           
> </home/rshepard/data/grassdata/willamette_basin/willamette-river-hg>
>           by driver <pg>
> DBMI-PostgreSQL driver error:
> Connection failed.
> FATAL:  database 
> "/home/rshepard/data/grassdata/willamette_basin/willamette-river" does 
> not exist
> 

I think you need to slow down a bit and try to review your basic 
understanding of things (maybe [1] could do with a bit more substance).

You are trying to connect to a database that is called 
"/home/rshepard/data/grassdata/willamette_basin/willamette-river-hg", 
not (as it should be) "willamette-river-hg".

Also, as MarkusM has already mentioned:

- db.connect does not test for the existence of the database. It just 
sets the content of the file definining the default mapset connection 
and outputs the content of this file. Use db.test to test your connection.

- The same goes for db.login: it just writes out the login info into a 
file. AFAIR, it is not absolutely necessary to use db.login to be able 
to connect to a database, especially if you do not need a password for 
connection.

- If you want to check the database connection of a specific vector map, 
please use v.db.connect -p.

Moritz



[1] https://grass.osgeo.org/grass74/manuals/databaseintro.html


More information about the grass-user mailing list