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.connectv.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
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms