Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. ogr2ogr -f PostgreSQL PG:"host=server_ip user=username dbname=dbname password=password" yourshapefile.shp;
  2.  
  3. $username = 'your_username';
  4. $password = 'your_password';
  5. $dbname = 'target_databasename';
  6. $tbname = 'target_tablename';
  7. $srsname = 'reference_system';
  8. $fileName = 'shapefile_name';
  9. $directory = '\directory\' .$fileName. '.shp';
  10. $shellCommand = "shp2pgsql -I -s " .$srsname. " " .$directory. " public." .$tbname. " | psql -U " .$username. " -d " .$dbname."";
  11. $shapfileLoader = exec($shellCommand,$stdOut,$stdErr);
  12. if (!$stdErr) {
  13. echo $stdOut;
  14. } else {
  15. echo $stdErr;
  16. }
  17.  
  18. var express = require('express');
  19. var router = express.Router();
  20. var { exec } = require('child_process');
  21.  
  22. router.post("/", function (_req, _res, _next) {
  23. const postGISdb = 'db_name';
  24. const user = 'your_username';
  25. exec(`psql -U ${user} -d ${postGISdb}`, (err, stdOut, stdErr) => {
  26. console.log(stdOut)
  27. })
  28. });
  29.  
  30. module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement