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

st_kiefer at web.de st_kiefer at web.de
Thu Nov 8 00:13:33 PST 2018


Hi Rich,
if you use a postgres database (driver=pg) you have to specify the full connection string to the database. You can see this in the manual for db.connect (look for PostgreSQL):

"
db.connect driver=pg database="host=myserver.itc.it,dbname=mydb"
..."

I.e. if the db is on your local machine the host is your IP adress or "localhost":

db.connect driver=pg database="host=localhost,dbname=willamette-river-hg"

If you use a Sqlite database you can omit driver specification, because that is the default.

regards.

Stefan


> Rich Shepard <rshepard at appl-ecosys.com> hat am 7. November 2018 um 23:44 geschrieben:
> 
> 
> On Wed, 7 Nov 2018, Rich Shepard wrote:
> 
> > Almost all issues are now resolved,
> 
>    The issues with specifying database paths and needing a filled cat column
> in the stations table have been resolved. v.db.connect shows a valid
> connection to the database table:
> 
> > v.db.connect map=stations -p
> Vector map <stations> is connected by:
> layer <1/stations> table <stations> in database
> </home/rshepard/data/grassdata/willamette_basin/willamette-river-hg> through
> driver <pg> with key <cat>
> 
> but, trying to display that map using v.colors in a script still fails to
> find the database:
> 
> > $HOME/documents/white-papers/geochemistry/willamette-river-mercury/scripts/grass-display-sample-sites.sh
> d.vect complete.
> d.vect complete.
> 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>
> ERROR: Unable to open database
>         </home/rshepard/data/grassdata/willamette_basin/willamette-river-hg>
>         by driver <pg>
> 
>    The script:
> #!/usr/bin/bash
> 
> db.connect driver=pg database=willamette-river-hg
> g.region vect=wrb
> d.mon start=wx0
> d.vect map=wrb col=black fill_col=none
> d.vect map=wrb_rivers col=blue fill_col=blue
> v.colors map=stations use=attr column=howmany rules=rules.txt rgb_col=bin_col --o
> 
> and the color rules file:
> 
> 1 231:00:00
> 10 231:00:00
> 11 89:00:00
> 20 89:00:00
> 21 231:00:231
> 30 231:00:231
> 31 231:173:00
> 40 231:173:00
> 41 231:115:00
> 50 231:115:00
> 51 00:231:57
> 60 00:231:57
> 61 115:231:00
> 70 115:231:00
> 
> TIA,
> 
> Rich
> 
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user


More information about the grass-user mailing list