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

zhang zhe luckyclare at hotmail.com
Mon Dec 13 03:22:57 PST 2010


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:)
  		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20101213/ea697704/attachment.html>


More information about the postgis-users mailing list