<html><body>Hi, <br>is there any possibility to download data into local grass database (topologcal) from remote postgis server? (without getting error)<br>Or is the issue still pending? (http://osgeo-org.1560.x6.nabble.com/Unable-to-link-to-postgis-postgresql-td5285313.html)<br>I am using Python to work with GRASS. And honestly, I got lost in outputs of db.* functions:<br><br>#set database and login<br>gscript.run_command('db.connect', database="host=172.21.3.20,dbname=mydb", driver="pg", verbose = True)<br>gscript.run_command('db.login', user="dbusername", password="passwd", overwrite = True)<br><br>#verifying connection<br>gscript.run_command('db.connect', flags='p')<br>output:<br><span style="font-size:12px">driver: pg<br>database: host=172.21.3.20,dbname=mydb<br>schema: <br>group: </span><br>#so everything looks fine so far<br><br>#here comes the trouble - simple list tables in db<br>gscript.run_command('db.tables', flags='p', verbose = True)<br>output:<br><span style="font-size:12px">DBMI-PostgreSQL driver error:<br>Connection failed.<br>could not connect to server: No such file or directory<br> Is the server running locally and accepting<br> connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?<br><br>DBMI-PostgreSQL driver error:<br>Connection failed.<br>could not connect to server: No such file or directory<br> Is the server running locally and accepting<br> connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?<br><br>ERROR: Unable to open database <host=172.21.3.20,dbname=mydb><br></span><i><br>#but for example:<br>gscript.run_command('v.external',<br> input="PG:dbname=mydb host=172.21.3.20",<br> flags='l', overwrite = True)<br>output:<br><span style="font-size:12px">--actuall list of all tables in mydb - so i CAN connect to the server!</span><br><br>#same for mapping external link - following will create external link<br>gscript.run_command('v.external',<br> input="PG:dbname=mydb host=172.21.3.20 user=dbusername password=password",<br> layer="myschema.mytable", output='outpoints, overwrite = True)<br>output:<br><span style="font-size:12px">WARNING: No key column detected.<br>WARNING: Feature table <outpoints> has no primary key defined. Unable to<br> define DB links.<br>WARNING: Feature table <outpoints> has no primary key defined<br>WARNING: Random read is not supported for this layer. Unable to build<br> topology.<br>v.external complete. Link to vector map <outpoints> created.</span><br><br>#weird, because i have primary key defined in the table, following is printing description of that external link<br>gscript.vector_info("outpoints")<br><br>#if i try to load data from database<br>gscript.run_command('v.in.ogr',<br> input="PG:dbname=mydb host=172.21.3.20",<br> layer='myschema.mytable',geometry="mygeomcolumn", output = "outpoints2", overwrite = True, type="point")<br>output:<br></i><span style="font-size:12px">Check if OGR layer <myschema.mytable> contains polygons...<br> 100%�����<br>WARNING: Vector map <</span><span style="font-size:12px"><i>outpoints2</i>> already exists and will be overwritten<br>DBMI-PostgreSQL driver error:<br>Connection failed.<br>could not connect to server: No such file or directory<br> Is the server running locally and accepting<br> connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?<br><br>DBMI-PostgreSQL driver error:<br>Connection failed.<br>could not connect to server: No such file or directory<br> Is the server running locally and accepting<br> connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?<br><br>WARNING: Unable to open database <host=172.21.3.20,dbname=macfishdb> by<br> driver <pg><br>WARNING: Unable open database <host=172.21.3.20,dbname=macfishdb> by driver<br> <pg><br>WARNING: Unable to find table <outpoints2> linked to vector map <lp_grass><br>Creating attribute table for layer <at_macfish.loggerpos>...<br>DBMI-PostgreSQL driver error:<br>Connection failed.<br>could not connect to server: No such file or directory<br> Is the server running locally and accepting<br> connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?<br><br>DBMI-PostgreSQL driver error:<br>Connection failed.<br>could not connect to server: No such file or directory<br> Is the server running locally and accepting<br> connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?<br><br>WARNING: Unable to open database <host=172.21.3.20,dbname=mydb> by<br> driver <pg><br>ERROR: Unable to open database <host=172.21.3.20,dbname=mydb> by<br> driver <pg><br><br><span style="font-size:20px"><span style="font-size:16px">My version of grass:</span><br><span style="font-size:12px">GRASS version: 7.4.0 <br>GRASS SVN revision: exported <br>Build date: 2018-01-26 <br>Build platform: x86_64-pc-linux-gnu <br>GDAL: 2.2.2 <br>PROJ.4: 4.9.2 <br>GEOS: 3.5.1 <br>SQLite: 3.11.0 <br>Python: 2.7.12 <br>wxPython: 3.0.2.0 <br>Platform: Linux-4.4.0-112-generic-x86_64-with-Ubuntu-16.04-xenial </span><br><br></span><span style="font-size:20px"></span><span style="font-size:16px">Version of python:</span></span><br><span style="font-size:12px">
</span><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-size:12px">Python 2.7.12 64bits</span></p><span style="font-size:12px"><br><span style="font-size:16px">Content of my .grass7/dblogin:</span><br>pg|host=172.21.3.20, dbname=mydb|dbusername|passwd||<br>sqlite|$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db|dbusername|passwd||<br>pg|macfishdb|dbusername|passwd||<br>pg|host=172.21.3.20,dbname=mydb|dbusername|passwd||<br><br>Thank you for any comment<br>Dead Vil<br><br><br></span><i><br></i></body></html>