GRASS GIS 7 Programmer's Manual
GRASS DataBase Management Interface

by GRASS Development Team


The attribute management was completely changed in GRASS 6 to achieve multi-attribute capabilities managed within external databases. The former dig_cats/ files (GRASS 5) are not used any more and all vector attributes are stored in external database. Connection with database is done through DBMI library (DataBase Management Interface) with its integrated drivers. At time of this writing following DBMI drivers for attribute storage are available:

These drivers are compiled depending on present DB related libraries and 'configure' settings. Only the DBF driver is always compiled. The default DBMI driver is defined in dbmi.h

#define DB_DEFAULT_DRIVER "sqlite"

In general records in table are linked to vector entities by field number and category number. The field number identifies a database table and the category number identifies the record record. I.e. for unique combination mapset + map + field + category exists one unique combination driver + database + table + row. Each element may have none, one or more categories (cats). More cats are distinguished by field number (field). The flexibility of this approach even supports the extreme case, that one vector entity may be linked to attributes in different tables in different databases connected by different drivers at the same time.

The DBMI library contains drivers such as DBF, SQLite, ODBC, MySQL and PostgreSQL. The functionality of the database support varies with the capabilities of the underlying RDBMS. Main features are multi-attributes support for various data types, also multiple tables may optionally be linked to one or many vector entity/ies. SQL (Structured Query Language) is used for all drivers, but in a limited implementation.

For DBMI architecture details please read Blazek et al. 2002 (see below).

DBMI library functions

The db_*() functions are the programmer's API for GRASS DBMI programming. There are three groups:

  • dbmi_base: contains functions for modules, drivers (../../db/drivers/)
  • dbmi_client: contains functions for modules
  • dbmi_driver: contains functions for drivers (../../db/drivers/)

DBMI BASE functions


String manipulation:

Column properties:

Connection settings:

Cursor management:

DateTime conversion:

DBmscap management:

Default settings:

Dirent (directory entities) array:

Report errors:

Handle management:

Index management:

Range functions:

Login functions:

Return codes (internal use only):

Data type conversion:

String manipulation:

Table/privileges management:

Token management:

Value management:


DBMI CLIENT functions

DBMI DRIVER functions


Text based on: R. Blazek, M. Neteler, and R. Micarelli. The new GRASS 5.1 vector architecture. In Open source GIS - GRASS users conference 2002, Trento, Italy, 11-13 September 2002. University of Trento, Italy, 2002.

See Also

GRASS Vector Architecture: GRASS Vector Library


  • Joel Jones (CERL/UIUC)
  • Radim Blazek