grass-odbc(1)
π ODBC DATABASE DRIVER π
hii bestie, welcome to grass-odbc(1) β the plug that lets GRASS and an ODBC database talk about attributes like the besties they are π«Ά it's all about communication between GRASS and ODBC database for attribute management, and the whole pipeline goes a lil something like this:
GRASS module <-> ODBC Interface <-> RDBMS
GRASS
DBMI driver
unixODBC
ODBC driver
PostgreSQL
Oracle
...
so yeah, GRASS on one end, your RDBMS on the other (PostgreSQL, Oracle, and friends), with the ODBC Interface living its best life in the middle β¨
β¨ Supported SQL commands
literally all of them. every SQL command that ODBC supports is supported here. periodt π
β¨ Operators available in conditions
same energy β all SQL operators supported by ODBC. all of them. no notes π
πΈ EXAMPLE πΈ
ok so in this example we're gonna copy the dbf file of a SHAPE map into ODBC, and then connect GRASS to the ODBC DBMS π¦ usually the table will already be sitting there in the DBMS, but we're doing the whole thing from scratch for the vibes.
π Defining the ODBC connection π
π₯οΈ MS-Windows
on MS-Windows, to be able to connect, the ODBC connection needs to be configured using dedicated tools (the tool is literally called "ODBC Data Source Administrator") and you gotta give a name to that connection. that name is then used as the database name when accessing from a client via ODBC. iykyk π
π§ Linux
configure the ODBC driver for the selected database (manually, or with βODBCConfigβ). ODBC drivers are defined in /etc/odbcinst.ini. here's an example:
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/libodbcpsql.so
Setup = /usr/lib/libodbcpsqlS.so
FileUsage = 1
then create the DSN (data source name). the DSN is used as the database name in db.* modules. the DSN must be defined in $HOME/.odbc.ini (for this user only) or in /etc/odbc.ini (for all users).
β οΈ watch out for the database name which appears twice, and also for the PostgreSQL protocol version. and omit blanks at the beginning of lines β no leading spaces bestie, i'm serious π
[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 =
configuration of a DSN without a GUI is described on https://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 with βDataManagerβ. configuration with GUI is described on https://www.unixodbc.org/doc/UserManual/ π
to find out about your PostgreSQL protocol, run:
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):
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 works):
db.tables -p
db.columns table=mytable
now the table name βmytableβ should appear π
doesn't work? check with βisql <databasename>β if the ODBC-PostgreSQL connection is really established π
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:
v.db.connect -p mytable.shp
which should print the database connection through ODBC to the defined RDBMS. slay.
π SEE ALSO
db.connectv.db.connect- unixODBC web site
- SQL support in GRASS GIS
π SOURCE CODE
available at: ODBC DATABASE DRIVER source code (history)
accessed: Saturday Jan 17 05:40:32 2026
main index | topics index | keywords index | graphical index | full index
and that's the whole page bestie π«Ά this was grass-odbc(1) from the GRASS GIS 8.4.2 Reference Manual β Β© 2003-2025 GRASS Development Team, and the footer energy is pure GRASS 8.4.2 / grass-odbc(1). go connect something iconic πβ¨π
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· 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