[postgis-users] loading sql files using batch commands - psql
Mike Toews
mwtoews at gmail.com
Tue Nov 20 12:34:03 PST 2012
Hi Mark,
Look into the .pgpass file[1], which is used to store a user's
password in plain text in the user's home directory. Several
PostgreSQL applications use the password file, including psql, pgAdmin
III. One notable exception that doesn't yet use the password file is
pgsql2shp [2].
After you have this file configured for the user/database, the
password will not be required or prompted for your psql command below.
-Mike
[1] http://www.postgresql.org/docs/current/static/libpq-pgpass.html
[2] http://trac.osgeo.org/postgis/ticket/398
On 21 November 2012 08:01, Mark Volz <MarkVolz at co.lyon.mn.us> wrote:
> Hello,
>
> I am trying to create a batch program that will update postgis from a directory of shapefiles. I came across http://suite.opengeo.org/opengeo-docs/dataadmin/pgGettingStarted/shp2pgsql.html, which uses psql to load data into postgis. The psql command appears to prompt for a password, which would be fine if I was manually running the batch file. However, I want to set up a scheduled task in windows so that my data gets updated on automatic intervals.
>
> Is there a way to store a password in a batch file such as " for %%f in (*.sql) do psql -p 5432 -w -U postgres --password mypassword --dbname postgis20 -f %%f?
> If not is there a way to trick a windows batch file to send the password to psql?
>
> Thanks for any help
>
> Mark Volz
> GIS Specialist
More information about the postgis-users
mailing list