<html><head><base href="x-msg://75/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Can you not just pipe it in : (from the manual)<div><br></div><div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, Helvetica, sans-serif; color: rgb(46, 46, 46); font-size: 14px; "><pre class="programlisting" style="border-right-width: 0px; border-left-width: 0px; border-bottom-width: 2px; border-top-width: 2px; font-family: 'Courier New', Courier, Monaco, monospace; line-height: 16px; border-top-color: rgb(247, 147, 30); border-right-color: rgb(247, 147, 30); border-bottom-color: rgb(247, 147, 30); border-left-color: rgb(247, 147, 30); border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; font-size: 11px; margin-bottom: 10px; margin-top: 10px; overflow-x: auto; overflow-y: auto; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(248, 248, 249); border-top-left-radius: 2px 2px; border-top-right-radius: 2px 2px; border-bottom-right-radius: 2px 2px; border-bottom-left-radius: 2px 2px; background-position: initial initial; background-repeat: initial initial; ">shp2pgsql shaperoads.shp myschema.roadstable | psql -d roadsdb</pre></span><div><br></div></div><div>or use the \i metacommand to run the created script.</div><div><br></div><div>cheers</div><div><br></div><div>Ben</div><div><br></div><div><br></div><div><br><div><div>On 13/12/2010, at 10:22 PM, zhang zhe wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; ">Hello,<br> <br>Does anyone know how to import sql table or shape file to postgres database automatically?<span class="Apple-converted-space"> </span><br>What I did before is:<br>I have shpe file save in C:/users<br>I go to terminal in linux, and go to the directory C:/users<span class="Apple-converted-space"> </span><br>C:/users<span class="Apple-converted-space"> </span><span style="font-family: 'Times New Roman'; font-size: 12pt; ">shp2pgsql shapefile.shp > sqlfile.sql</span><br><span style="font-family: 'Times New Roman'; font-size: 12pt; ">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.<span class="Apple-converted-space"> </span></span><br><span style="font-family: 'Times New Roman'; font-size: 12pt; "></span> <br><span style="font-family: 'Times New Roman'; font-size: 12pt; ">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?<span class="Apple-converted-space"> </span></span><br><span style="font-family: 'Times New Roman'; font-size: 12pt; "></span> <br><span style="font-family: 'Times New Roman'; font-size: 12pt; ">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.</span><br><span style="font-family: 'Times New Roman'; font-size: 12pt; "></span> <br><span style="font-family: 'Times New Roman'; font-size: 12pt; ">$query 1="import sql table to postgres";</span><br><span style="font-family: 'Times New Roman'; font-size: 12pt; ">pg_query($query1) or die ('query1 failed'. pg_last_erro());</span><br><span style="font-family: 'Times New Roman'; font-size: 12pt; "></span> <br><span style="font-family: 'Times New Roman'; font-size: 12pt; ">Is there any query could import sql table to postgres automatically?<span class="Apple-converted-space"> </span></span><br><span style="font-family: 'Times New Roman'; font-size: 12pt; "></span> <br><span style="font-family: 'Times New Roman'; font-size: 12pt; ">Thanks a lot:)</span><br><span style="font-family: 'Times New Roman'; font-size: 12pt; "></span> <br>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></div></span></blockquote></div><br></div></body></html>