<div dir="ltr">Brent:<div><br></div><div style>Aha! I noticed the pipe in the book's listing, but it's at the line break and I assumed it's was the book's nomenclature indicating it was all one line. It also explains the "psql" option (that's the 2nd command, not an option).</div>
<div style><br></div><div style>I put in the pipe and re-ran. It prompted me for password, and replied with a bunch of "INSERT 0 1" lines, ending with "COMMIT".</div><div style><br></div><div style>I now see that I have a public.us_counties table.</div>
<div style><br></div><div style>Looks like I have data in it, too. Awesome. Thanks, Brent.</div><div style><br></div><div style>David</div><div style><br></div><div style><br></div></div><div class="gmail_extra"><br><br>
<div class="gmail_quote">On Fri, Apr 12, 2013 at 6:25 PM, <span dir="ltr"><<a href="mailto:pcreso@pcreso.com" target="_blank">pcreso@pcreso.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">Hi David,<br><br>Are you familiar with the terms STDIN & STDOUT?<br><br>They are the system devices for input & output. <br>
<br>shp2pgsql sends its output to STDOUT which is generally the screen - standard output device. So what you see on screen is what you want to send to the database - all the commands to create the appropriate table and insert the shapefile data in the new table.<br>
<br>What you need to do is redirect the STDOUT content to the database instead, done easily enough by adding a "|" (pipe) character before your psql command. This redirects the shp2pgsql output to become input to the psql command instead of sending it to the screen.<br>
<br>so your command becomes:<div class="im"><br><br>shp2pgsql -s 4269 -g geom_4269 -W LATIN1
c:/users/david/downloads/tl_2012_us_county/tl_2012_us_county.shp
public.us_counties | psql -h localhost -U postgres -p 5432 -d mygisdb <br><br></div>Cheers,<br><br> Brent Wood<br><br><br><br><br><br>--- On <b>Sat, 4/13/13, David Rush <i><<a href="mailto:david@rushtone.com" target="_blank">david@rushtone.com</a>></i></b> wrote:<br>
<blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px"><br>From: David Rush <<a href="mailto:david@rushtone.com" target="_blank">david@rushtone.com</a>><br>Subject: [postgis-users] Noob question with shp2pgsql<br>
To: <a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>Date: Saturday, April 13, 2013, 10:14 AM<div><div class="h5"><br><br><div><div dir="ltr">Total noob to PostgreSQL and PostGIS here. Trying to follow examples from the Obe+Hsu book (1st Ed) in using shp2pgsql from the command line to import some tiger county data.<div>
<br></div><div>I ran this:</div>
<div><br></div><div>shp2pgsql -s 4269 -g geom_4269 -W LATIN1 c:/users/david/downloads/tl_2012_us_county/tl_2012_us_county.shp public.us_counties psql -h localhost -U postgres -p 5432 -d mygisdb <br></div><div>
<br></div><div>Thanks to an archive of this list that led me to add the "-W LATIN1" param (it was failing with an error w/out it).</div><div><br></div><div>Now the command runs for several minutes, spitting out mostly zillions of hex digits, with no overt errors. Last line it spits out is "COMMIT;".</div>
<div><br></div><div>But when I go into psql, I can't find the public.us_counties table that I thought I just added created:</div><div><br></div><div><div>mygisdb=# select * from public.us_counties;</div>
<div>ERROR: relation "public.us_counties" does not exist</div><div>LINE 1: select * from public.us_counties;</div><div> ^</div><div>mygisdb=# select table_schema, table_name,table_type from information_schema.tables where</div>
<div>table_schema not in ('pg_catalog','information_schema');</div><div> table_schema | table_name | table_type</div><div>--------------+-------------------+------------</div><div> public | geography_columns | VIEW</div>
<div> public | geometry_columns | VIEW</div><div> public | spatial_ref_sys | BASE TABLE</div><div> ch01 | lu_franchises | BASE TABLE</div><div> ch01 | fastfoods | BASE TABLE</div>
<div>(5 rows)</div><div><br></div><div>Poking around with pgAdmin III I can't find in anywhere, either.</div><div><br></div><div>Is the new table us_counties hiding somewhere? Or did it quietly fail? Or what?</div>
<div><br></div><div>David</div></div></div>
</div><br></div></div>-----Inline Attachment Follows-----<br><br><div>_______________________________________________<br>postgis-users mailing list<br><a href="http://mc/compose?to=postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></div></blockquote></td></tr></tbody></table></blockquote></div>
<br></div>