[GRASSweb-list]markus: web/grass51 examples.html,1.5,1.6

grass at intevation.de grass at intevation.de
Mon Nov 4 12:38:26 EST 2002


Author: markus

Update of /grassrepository/web/grass51
In directory doto:/tmp/cvs-serv2321

Modified Files:
	examples.html 
Log Message:
SQL example

Index: examples.html
===================================================================
RCS file: /grassrepository/web/grass51/examples.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- examples.html	4 Nov 2002 16:54:39 -0000	1.5
+++ examples.html	4 Nov 2002 17:38:24 -0000	1.6
@@ -230,14 +230,12 @@
  Driver                = PostgreSQL
  Trace                 = No
  TraceFile             =
-
  Database                = grass51test
  Servername              = localhost
  UserName                =
  Password                =
  Port                    = 5432
  Protocol                = 7.0.3
-
  ReadOnly                = No
  RowVersioning           = No
  ShowSystemTables        = No
@@ -271,6 +269,11 @@
 <li>Next we dump the DBF file into PostgreSQL (NOTE: unless a
             'db.copy' does not exist, we use 'pg.in.dbf' from GRASS 5.0):
 <pre>
+#go to directory, where registered SHAPE/DBF files are:
+cd `g.gisenv GISDBASE`
+cd `g.gisenv LOCATION_NAME`
+cd shp
+
 pg.in.dbf in=markveggy.dbf dumpmode=normal 
 </pre>
 
@@ -286,25 +289,30 @@
       link to PostgreSQL through ODBC</h2>
 
 <pre>
-#go to directory, where registered SHAPE/DBF files are:
+#edit DB file and create an entry
 cd `g.gisenv GISDBASE`
 cd `g.gisenv LOCATION_NAME`
-cd shp
+cd `g.gisenv MAPSET`
 
-Now you have to use "createdb" do create database tables.
-First we create an empty table:
-createdb humus This new table we select in GRASS:
-g.select.pg database=humus To destroy a database use: "destroydb humus" (PostgreSQL 6.x) or "dropdb humus" (PostgreSQL 7.x).
+#change existing 'markveggy.shp' to ODBC driver:
+markveggy.shp 1 markveggy VEGCNP_ID /ssi0/ssi/neteler/grassdata/botswanaLL/shp 
 
-In this first step we import the plain attribute table only without importing geographical features.
-To import the Dbase-table into PostgreSQL enter:
-pg.in.dbf in=humus.dbf
-  Executing create table humus (AREA float4,PERIMETER float4,G2_UEB09_
-  int8,G2_UEB09_I int8,STONR int4,BOTYP text,HORIZ text,BODART text,HUMUS
-  float4,SKELETT text) You will be asked: Additionally dump to ASCII file (enter full Unix name or hit  <return> for none):
-Enter "ENTER" if you don't need an additional ASCII file in your local directory.
+#check settings
+db.connect -p
 
-The table is imported into PostgreSQL now.
+#this should print the table name:
+db.tables
+</pre>
+
+
+<h2>Example 8: SQL queries</h2>
+
+<pre>
+#Select from table 'markveggy' (in database 'grass51test') all rows where 'vegtype = PS':
+#NOTE: string attributes must be quoted:
+echo "select * from markveggy where vegtype = 'PS'" | db.execute
+
+#to be cont'ed...
 </pre>
 
 <!-- FOOTER -->





More information about the grass-web mailing list