1grass-odbc(1)                 Grass User's Manual                grass-odbc(1)
2
3
4
5ODBC  driver  in  GRASS  Communication  between  GRASS  and  ODBC database for
6attribute management:
7GRASS module ODBC Interface RDBMS GRASS DBMI driver unixODBC ODBC driver Post‐

greSQL Oracle ...

9

Supported SQL commands

11       All SQL commands supported by ODBC.
12

Operators available in conditions

14       All SQL operators supported by ODBC.
15

EXAMPLE

17       In  this  example  we  copy the dbf file of a SHAPE map into ODBC, then
18       connect GRASS to the ODBC DBMS.  Usually  the  table  will  be  already
19       present in the DBMS.
20
21                     Configure  ODBC driver for selected database (manually or
22                     with  'ODBCConfig').   ODBC  drivers   are   defined   in
23                     /etc/odbcinst.ini. Here is example:
24                      [PostgreSQL]
25                      Description     = ODBC for PostgreSQL
26                      Driver          = /usr/lib/libodbcpsql.so
27                      Setup           = /usr/lib/libodbcpsqlS.so
28                     FileUsage       = 1
29
30                      Create  DSN (data source name). The DSN is used as data‐
31                     base name in db.*  modules. Then DSN must be  defined  in
32                     $HOME/.odbc.ini  (for this user only) or in /etc/odbc.ini
33                     for (for all users) [watch  out  for  the  database  name
34                     which  appears twice and also for the PostgreSQL protocol
35                     version]. Omit blanks at the beginning of lines:
36                      [grass6test]
37                      Description             = PostgreSQL
38                      Driver                  = PostgreSQL
39                      Trace                   = No
40                      TraceFile               =
41                      Database                = grass6test
42                      Servername              = localhost
43                      UserName                = neteler
44                      Password                =
45                      Port                    = 5432
46                      Protocol                = 8.0
47                      ReadOnly                = No
48                      RowVersioning           = No
49                      ShowSystemTables        = No
50                      ShowOidColumn           = No
51                      FakeOidIndex            = No
52                     ConnSettings            = Configuration of an DSN without
53                     GUI              is              described             on
54                     http://www.unixodbc.org/odbcinst.html, but  odbc.ini  and
55                     .odbc.ini  may  be  created by the 'ODBCConfig' tool. You
56                     can easily view your DSN structure by 'DataManager'. Con‐
57                     figuration      with      GUI     is     described     on
58                     http://www.unixodbc.org/doc/UserManual/
59
60              To find out about your PostgreSQL protocol, run:
61
62              psql -V
63
64
65                     Now create a new database if not yet existing:
66                     db.createdb driver=odbc database=grass6test
67
68
69                     Now store  the  table  'mytable.dbf'  (here:  in  current
70                     directory) into PostgreSQL through ODBC:
71                     db.connect driver=odbc database=grass6test
72                     db.copy    from_driver=dbf    from_database=./   from_ta‐
73                     ble=mytable \
74                             to_driver=odbc   to_database=grass6test    to_ta‐
75                     ble=mytable
76
77
78                      Next  link map to attribute table (now the ODBC table is
79                     used, not the dbf file):
80                     v.db.connect map=mytable.shp table=mytable key=ID \
81                                  database=grass6test driver=odbc
82                     v.db.connect -p
83
84
85                     Finally a test: Here we should see the table columns  (if
86                     the ODBC connection works):
87                     db.tables -p
88                     db.columns table=mytable
89                      Now the table name 'mytable' should appear.
90
91              Doesn't  work? Check with 'isql ' if the ODBC-PostgreSQL connec‐
92              tion is really established.
93       Note that you can also connect  mySQL,  Oracle  etc.  through  ODBC  to
94       GRASS.   You  can also check the vector map itself concerning a current
95       link to a table:
96       v.db.connect -p mytable.shp
97        which should print the database connection through ODBC to the defined
98       RDBMS.
99

SEE ALSO

101       unixODBC web site, SQL support in GRASS GIS
102
103       Last changed: $Date: 2006/08/24 19:11:36 $
104       Help Index
105
106
107
108GRASS 6.2.2                                                      grass-odbc(1)
Impressum