grass-odbc(1grass)

ODBC DATABASE DRIVER πŸ’…

okay bestie, so this is grass-odbc, a manual page from the GRASS User's Manual, and it's all about making GRASS and an ODBC database talk to each other for attribute management. no cap, it's giving "matchmaker but make it SQL". here's the whole vibe:

Communication between GRASS and ODBC database for attribute management:
GRASS module <->                                             <-->                                                         ODBC Interface                                               <-->                                                         RDBMS

GRASS                                                        DBMI driver                                                  unixODBC                                                     ODBC driver                                                  PostgreSQL

Oracle

...

like, the pipeline is: GRASS β†’ DBMI driver β†’ unixODBC β†’ ODBC driver β†’ your RDBMS. PostgreSQL? Oracle? the ... is doing a lot of heavy lifting there and honestly, iconic. πŸ‘‘


Supported SQL commands ✨

every single SQL command that ODBC supports. all of them. the whole buffet. πŸ“

Operators available in conditions 🌸

all the SQL operators that ODBC supports. again β€” if ODBC's got it, you've got it. periodt. πŸ’…


EXAMPLE πŸ¦‹

so in this example we're literally copying the dbf file of a SHAPE map into ODBC, and then we connect GRASS to the ODBC DBMS. ngl tho β€” usually the table will already be there in the DBMS, so don't stress if your situation's a little more chill than this one. 😌

Defining the ODBC connection

MS-Windows πŸŽ€

on MS-Windows, to be able to connect, you have to set up the ODBC connection using the dedicated tools β€” there's a tool called "ODBC Data Source Administrator" β€” and then give that connection a name. that name is then used as the database name when you're accessing from a client via ODBC. that's the whole thing. 🀝

Linux 🐧

configure the ODBC driver for the database you picked (either manually or with ’ODBCConfig’). ODBC drivers are defined in /etc/odbcinst.ini. here's an example, bestie:

[PostgreSQL]
Description     = ODBC for PostgreSQL
Driver          = /usr/lib/libodbcpsql.so
Setup           = /usr/lib/libodbcpsqlS.so
FileUsage       = 1

then create a DSN (data source name). the DSN is used as the database name in the db.* modules. after that, the DSN has to be defined in $HOME/.odbc.ini (for this user only) or in /etc/odbc.ini (for all users).

⚠️ watch out for the database name that appears twice, and also watch out for the PostgreSQL protocol version. and please β€” omit blanks at the beginning of lines. πŸ™ˆ
[grass6test]
Description             = PostgreSQL
Driver                  = PostgreSQL
Trace                   = No
TraceFile               =
Database                = grass6test
Servername              = localhost
UserName                = neteler
Password                =
Port                    = 5432
Protocol                = 8.0
ReadOnly                = No
RowVersioning           = No
ShowSystemTables        = No
ShowOidColumn           = No
FakeOidIndex            = No
ConnSettings            =

configuring a DSN without a GUI is described on https://www.unixodbc.org/odbcinst.html, but odbc.ini and .odbc.ini can also be created by the ’ODBCConfig’ tool. you can easily view your DSN structure with ’DataManager’. configuration with a GUI is described on https://www.unixodbc.org/doc/UserManual/.

wanna find out about your PostgreSQL protocol? run this:

psql -V

Using the ODBC driver πŸ”₯

now create a new database, if it's not already existing:

db.createdb driver=odbc database=grass6test

to store a table ’mytable.dbf’ (here: in the current directory) into PostgreSQL through ODBC, run:

db.connect driver=odbc database=grass6test
db.copy from_driver=dbf from_database=./ from_table=mytable \
        to_driver=odbc to_database=grass6test to_table=mytable

next, link the map to the attribute table (now the ODBC table is used, not the dbf file). slay:

v.db.connect map=mytable.shp table=mytable key=ID \
             database=grass6test driver=odbc
v.db.connect -p

finally, a test! here we should see the table columns (if the ODBC connection actually works, that is):

db.tables -p
db.columns table=mytable

now the table name ’mytable’ should appear. it's giving connected. ✨

doesn't work? 😭 check with ’isql <databasename>’ whether the ODBC-PostgreSQL connection is really established. vibe check your connection, fr fr.

note that you can also connect mySQL, Oracle, etc. through ODBC to GRASS. the versatility?? we love to see it. πŸ’–

you can also check the vector map itself concerning a current link to a table:

v.db.connect -p mytable.shp

which should print the database connection through ODBC to the defined RDBMS. and that's your proof bestie, no guessing required. 🫢


SEE ALSO πŸ‘‘

  • db.connect
  • v.db.connect
  • unixODBC web site
  • SQL support in GRASS

SOURCE CODE πŸ“œ

available at: ODBC DATABASE DRIVER source code (history)

accessed: Tuesday Sep 08 11:54:02 2026

Main index | Topics index | Keywords index | Graphical index | Full index


okay and that's the whole manual page!! πŸ’œ the sign-off goes like this: it's the GRASS 8.5.0 Reference Manual, Β© 2003-2026 GRASS Development Team, and this page is grass-odbc(1grass) running on GRASS 8.5.0. go connect something and make it beautiful. πŸ§šβ€β™€οΈπŸŒˆβœ¨

πŸ“¦ where this page comes from