issue loading shapefiles into postgis via batch

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

issue loading shapefiles into postgis via batch

Mark  Volz

Hello,

 

I am having issues with a Windows batch load script.  This script should scan for any new shapefiles in the “PostGIS Incoming” folder, load the shapefiles into postGIS, then place the shapefiles in a completed folder.  This script seemed to work in the past, but is now complaining about a password – which I did not change.

 

What is wrong with this script, and or what can I do to specify a password?

 

###########################################

#      LOAD SHAPEFILES INTO POSTGIS SCRIPT

###########################################

 

set PATH=C:\Program Files\PostgreSQL\9.2\bin;%PATH%

cd /d "D:\PostGISIncoming\LyonGIS"

rem load data to postgis

for %%f in (*.shp) do shp2pgsql -d -I -s 103749 -W LATIN1 %%f %%~nf | psql -w -U postgres -d lyongis

rem move data to done folder

for %%a in (*.*) do move "%%a" "D:\PostGISIncoming\LyonGIS\Done"

 

 

 

Thanks

Sincerely,

Mark Volz, GISP

 


_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: issue loading shapefiles into postgis via batch

Bo Victor Thomsen

There are several ways to do this. One of the easiest (and most insecure) is to set the PGPASSWORD environment variable with the password for "postgres" user in the script before the psql command.


Regards

Bo Victor Thomsen

AestasGIS

Denmark


Den 26/08/16 kl. 15:59 skrev Mark Volz:

Hello,

 

I am having issues with a Windows batch load script.  This script should scan for any new shapefiles in the “PostGIS Incoming” folder, load the shapefiles into postGIS, then place the shapefiles in a completed folder.  This script seemed to work in the past, but is now complaining about a password – which I did not change.

 

What is wrong with this script, and or what can I do to specify a password?

 

###########################################

#      LOAD SHAPEFILES INTO POSTGIS SCRIPT

###########################################

 

set PATH=C:\Program Files\PostgreSQL\9.2\bin;%PATH%

cd /d "D:\PostGISIncoming\LyonGIS"

rem load data to postgis

for %%f in (*.shp) do shp2pgsql -d -I -s 103749 -W LATIN1 %%f %%~nf | psql -w -U postgres -d lyongis

rem move data to done folder

for %%a in (*.*) do move "%%a" "D:\PostGISIncoming\LyonGIS\Done"

 

 

 

Thanks

Sincerely,

Mark Volz, GISP

 



_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users


_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: issue loading shapefiles into postgis via batch

Andy Colson
The other way is the pgpass file:

https://wiki.postgresql.org/wiki/Pgpass

-Andy


On 8/26/2016 12:27 PM, Bo Victor Thomsen wrote:

> There are several ways to do this. One of the easiest (and most
> insecure) is to set the PGPASSWORD environment variable with the
> password for "postgres" user in the script before the psql command.
>
>
> Regards
>
> Bo Victor Thomsen
>
> AestasGIS
>
> Denmark
>
>
> Den 26/08/16 kl. 15:59 skrev Mark Volz:
>>
>> Hello,
>>
>>
>>
>> I am having issues with a Windows batch load script.  This script
>> should scan for any new shapefiles in the “PostGIS Incoming” folder,
>> load the shapefiles into postGIS, then place the shapefiles in a
>> completed folder.  This script seemed to work in the past, but is now
>> complaining about a password – which I did not change.
>>
>>
>>
>> What is wrong with this script, and or what can I do to specify a
>> password?
>>
>>
>>
>> ###########################################
>>
>> #      LOAD SHAPEFILES INTO POSTGIS SCRIPT
>>
>> ###########################################
>>
>>
>>
>> set PATH=C:\Program Files\PostgreSQL\9.2\bin;%PATH%
>>
>> cd /d "D:\PostGISIncoming\LyonGIS"
>>
>> rem load data to postgis
>>
>> for %%f in (*.shp) do shp2pgsql -d -I -s 103749 -W LATIN1 %%f %%~nf |
>> psql -w -U postgres -d lyongis
>>
>> rem move data to done folder
>>
>> for %%a in (*.*) do move "%%a" "D:\PostGISIncoming\LyonGIS\Done"
>>
>>
>>
>>
>>
>>
>>
>> Thanks
>>
>> Sincerely,
>>
>> *Mark Volz, GISP***
>>
>>
>>
>>
>>
>> _______________________________________________
>> postgis-users mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/postgis-users
>
>
>
> _______________________________________________
> postgis-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/postgis-users
>

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: issue loading shapefiles into postgis via batch

Ben Madin-2
In reply to this post by Mark Volz
Rather than putting a password into a plain text file, we prefer to create a user with very limit priviliges - ie can only access one schema and can only create and insert into that schema and read nothing. Then in the pg_hba.conf give that user local access to your database using trust. 

In reality, whether you put in a plain text password or no password, it should only be for a user with limited priviliges, and no capacity to to access private data or damage the existing database. If you then limit their access from the local server, you are getting pretty secure. 

Cheers

Ben


On Friday, 26 August 2016, Mark Volz <[hidden email]> wrote:

Hello,

 

I am having issues with a Windows batch load script.  This script should scan for any new shapefiles in the “PostGIS Incoming” folder, load the shapefiles into postGIS, then place the shapefiles in a completed folder.  This script seemed to work in the past, but is now complaining about a password – which I did not change.

 

What is wrong with this script, and or what can I do to specify a password?

 

###########################################

#      LOAD SHAPEFILES INTO POSTGIS SCRIPT

###########################################

 

set PATH=C:\Program Files\PostgreSQL\9.2\bin;%PATH%

cd /d "D:\PostGISIncoming\LyonGIS"

rem load data to postgis

for %%f in (*.shp) do shp2pgsql -d -I -s 103749 -W LATIN1 %%f %%~nf | psql -w -U postgres -d lyongis

rem move data to done folder

for %%a in (*.*) do move "%%a" "D:\PostGISIncoming\LyonGIS\Done"

 

 

 

Thanks

Sincerely,

Mark Volz, GISP

 



--
Sent from my iPhone.

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users