.TH grass-odbc 1grass "" "GRASS 6.4.2" "Grass User's Manual" .SH NAME grass-odbc - ODBC driver ODBC driver ODBC driver in GRASS Communication between GRASS and ODBC database for attribute management: .br .br | GRASS module | | ODBC Interface | | RDBMS .br | \fI\fBGRASS\fR\fR | \fI\fBDBMI driver\fR\fR | \fI\fBunixODBC\fR\fR | \fI\fBODBC driver\fR\fR | \fI\fBPostgreSQL\fR\fR .br | \fI\fBOracle\fR\fR .br | \fI\fB...\fR\fR .SH Supported SQL commands All SQL commands supported by ODBC. .SH Operators available in conditions All SQL operators supported by ODBC. .SH EXAMPLE In this example we copy the dbf file of a SHAPE map into ODBC, then connect GRASS to the ODBC DBMS. Usually the table will be already present in the DBMS. .RS .IP Configure ODBC driver for selected database (manually or with 'ODBCConfig'). ODBC drivers are defined in /etc/odbcinst.ini. Here is example: \fC .DS .br [PostgreSQL] .br Description = ODBC for PostgreSQL .br Driver = /usr/lib/libodbcpsql.so .br Setup = /usr/lib/libodbcpsqlS.so .br FileUsage = 1 .DE \fR .IP Create DSN (data source name). The DSN is used as database name in db.* modules. Then DSN must be defined in $HOME/.odbc.ini (for this user only) or in /etc/odbc.ini for (for all users) [watch out for the database name which appears twice and also for the PostgreSQL protocol version]. Omit blanks at the beginning of lines: \fC .DS .br [grass6test] .br Description = PostgreSQL .br Driver = PostgreSQL .br Trace = No .br TraceFile = .br .br Database = grass6test .br Servername = localhost .br UserName = neteler .br Password = .br Port = 5432 .br Protocol = 8.0 .br .br ReadOnly = No .br RowVersioning = No .br ShowSystemTables = No .br ShowOidColumn = No .br FakeOidIndex = No .br ConnSettings = .DE \fR Configuration of an DSN without GUI is described on http://www.unixodbc.org/odbcinst.html, but odbc.ini and .odbc.ini may be created by the 'ODBCConfig' tool. You can easily view your DSN structure by 'DataManager'. Configuration with GUI is described on http://www.unixodbc.org/doc/UserManual/ .PP To find out about your PostgreSQL protocol, run: .br \fC .DS .br psql -V .br .DE \fR .IP Now create a new database if not yet existing: \fC .DS .br db.createdb driver=odbc database=grass6test .br .DE \fR .IP Now store the table 'mytable.dbf' (here: in current directory) into PostgreSQL through ODBC: \fC .DS .br db.connect driver=odbc database=grass6test .br db.copy from_driver=dbf from_database=./ from_table=mytable \(rs .br to_driver=odbc to_database=grass6test to_table=mytable .br .DE \fR .IP Next link map to attribute table (now the ODBC table is used, not the dbf file): \fC .DS .br v.db.connect map=mytable.shp table=mytable key=ID \(rs .br database=grass6test driver=odbc .br v.db.connect -p .br .DE \fR .IP Finally a test: Here we should see the table columns (if the ODBC connection works): \fC .DS .br db.tables -p .br db.columns table=mytable .br .br .DE \fR Now the table name 'mytable' should appear. .br Doesn't work? Check with 'isql ' if the ODBC-PostgreSQL connection is really established. .RE Note that you can also connect mySQL, Oracle etc. through ODBC to GRASS. You can also check the vector map itself concerning a current link to a table: \fC .DS .br v.db.connect -p mytable.shp .br .DE \fR which should print the database connection through ODBC to the defined RDBMS. .SH SEE ALSO \fI db.connect, v.db.connect, unixODBC web site, SQL support in GRASS GIS\fR .PP \fILast changed: $Date: 2011-02-07 18:59:50 +0100 (Mon, 07 Feb 2011) $\fR .br Help Index