[postgis-users] import shape or sql to postgres automatically

Ben Madin lists at remoteinformation.com.au
Mon Dec 13 13:44:58 PST 2010

Can you not just pipe it in : (from the manual)

shp2pgsql shaperoads.shp myschema.roadstable | psql -d roadsdb

or use the \i metacommand to run the created script.



On 13/12/2010, at 10:22 PM, zhang zhe wrote:

> Hello,
> Does anyone know how to import sql table or shape file to postgres database automatically? 
> What I did before is:
> I have shpe file save in C:/users
> I go to terminal in linux, and go to the directory C:/users 
> C:/users shp2pgsql shapefile.shp > sqlfile.sql
> I will get sql file saved into c:/users directory. I open the sql file copy all the sql query. After that I open postgres database, and paste all the query to sql query window, and run the query. I will have new table appear in the dabase. 
> Sometimes the sql table is too large, that I cannot paste them all in the postgres sql query window. Postgres is always get stuck because of the query is too large.For instance I have road dataset of whole contry, and it has really millions of queries. Is there any way to import shape file or sql table to Postgres database automatically without any manual work? 
> I am now developing a application in php. In php, is there method to import a sql table or shape file to Postgres automatically? I know with php there is way to connect postgres and run the query.
> $query 1="import sql table to postgres";
> pg_query($query1) or die ('query1 failed'. pg_last_erro());
> Is there any query could import sql table to postgres automatically? 
> Thanks a lot:)
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20101214/56f4efac/attachment.html>

More information about the postgis-users mailing list