I have two servers X and Y. X contains a postgis instance whereas Y doesn't have postgis installed, but connects to the postgis instance on X through a connector in nodejs.
I want the node script to import some shapefiles which is normally done with the pgsql2shp command. However since pgsql2shp isn't installed on server Y I can't just call the command.
Is there a way to call the pgsql2shp command (or do it's equivalent) through a query? Or should I just have the script on Y ssh to server X and run the command?
Best Answer
IMO it depends on what kind of access you have on db-server Y and the import format matters allways.
Push variant
You could redirect the output of
shp2pgsql ...
command from the maschine X to db-server Y with:(assuming you are in a unixoid environment).
But the db-server Y will not understand what
shp2pgsql ...
on maschine X is generating and talking about without a postgis extension.Pull variant
On the other you could import not postgis stuff like plain text files via COPY from inside the psql prompt and use tools like ssh to taylor the stuff before.
... or if you have generated some sql stuff as seen before..
If you exchange
some_converstion_tool_to_please_psql
withshp2pgsql
it describes the push variant.@Added central node.js variant
I'm not familar with node.js but following the examples above, you could combine a reader and a writer on our node.js environment. Here a plain non JSON example:
Create a shapefile with examples
The attributes
The geometry
Assuming the database table on db-server.Y:
Node script...