GRASS Programmer's Manual
6.5.svn(2014)-r66266
|
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 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 include/dbmi.h (#define DB_DEFAULT_DRIVER "dbf").
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).
The db_*() functions are the programmer's API for GRASS DBMI programming. There are three groups:
See details here:
[ to be moved here from below list ]
char *db_store (char *s)
void db_calloc (int n, int m)
void db_malloc (int n)
void db_realloc (void *s, int n)
void db_free (void *s, int n)
int db_nocase_compare (char *a, char *b)
void db_char_to_lowercase (char *s)
void db_char_to_uppercase (char *s)
void db_Cstring_to_lowercase (char *s)
void db_Cstring_to_uppercase (char *s)
int db_get_connection (dbConnection *connection )
int db_set_connection (dbConnection *connection )
dbTable *db_get_cursor_table (dbCursor *cursor)
dbToken db_get_cursor_token (dbCursor *cursor)
int db_alloc_cursor_column_flags (dbCursor *cursor)
int db_alloc_cursor_table (dbCursor *cursor, int ncols)
int db_get_cursor_number_of_columns (dbCursor *cursor)
int db_test_cursor_any_column_flag (dbCursor *cursor)
int db_test_cursor_any_column_for_update (dbCursor *cursor)
int db_test_cursor_column_flag (dbCursor *cursor, int col)
int db_test_cursor_column_for_update (dbCursor *cursor, int col)
int db_test_cursor_mode_insensitive (dbCursor *cursor)
int db_test_cursor_mode_scroll (dbCursor *cursor)
int db_test_cursor_type_fetch (dbCursor *cursor)
int db_test_cursor_type_insert (dbCursor *cursor)
int db_test_cursor_type_update (dbCursor *cursor)
void db_free_cursor_column_flags (dbCursor *cursor)
void db_free_cursor (dbCursor *cursor)
void db_init_cursor (dbCursor *cursor)
void db_set_cursor_column_flag (dbCursor *cursor, int col)
void db_set_cursor_column_for_update (dbCursor *cursor, int col)
void db_set_cursor_mode (dbCursor *cursor, int mode)
void db_set_cursor_mode_insensitive (dbCursor *cursor)
void db_set_cursor_mode_scroll (dbCursor *cursor)
void db_set_cursor_table (dbCursor *cursor, dbTable *table)
void db_set_cursor_token (dbCursor *cursor, dbToken token)
void db_set_cursor_type_insert (dbCursor *cursor)
void db_set_cursor_type_readonly (dbCursor *cursor)
void db_set_cursor_type_update (dbCursor *cursor)
void db_unset_cursor_column_flag (dbCursor *cursor, int col)
void db_unset_cursor_column_for_update (dbCursor *cursor, int col)
void db_unset_cursor_mode (dbCursor *cursor)
void db_unset_cursor_mode_insensitive (dbCursor *cursor)
void db_unset_cursor_mode_scroll (dbCursor *cursor)
char *#db_get_default_database ( void )
char *#db_get_default_driver ( void )
char *db_get_default_group_name ( void )
char *db_get_default_schema_name ( void )
int db_add_column (dbDriver driver, dbString *tableName, dbColumn column)
int db_bind_update (dbCursor *cursor)
int db_close_cursor (dbCursor *cursor)
int db_close_database (dbDriver driver)
int db_create_index (dbDriver driver, dbIndex index)
int db_create_table (dbDriver driver, dbTable *table)
int db_create_database (dbDriver driver, dbHandle *handle)
int db_delete (dbCursor *cursor)
int db_delete_database (dbDriver driver, dbHandle *handle)
int db_describe_table (dbDriver driver, dbString *name, dbTable *table)
int db_drop_column (dbDriver driver, dbString *tableName, dbString *columnName)
int db_drop_index (dbDriver driver, dbString *name)
int db_drop_table (dbDriver driver, dbString *name)
int db_begin_transaction (dbDriver driver)
int db_commit_transaction (dbDriver driver)
int db_execute_immediate (dbDriver driver, dbString *SQLstatement)
int db_fetch (dbCursor *cursor, int position, int more)
int db_find_database (dbDriver driver, dbHandle *handle, int found)
int db_insert (dbCursor *cursor)
char *db_list_drivers (void)
int db_list_indexes (dbDriver driver, dbString *table_name, dbIndex list, int count)
int db_list_tables (dbDriver driver, dbString *names, int count, int system)
int db_list_databases (dbDriver driver, dbString *path, int npaths, dbHandle *handles, int count)
int db_get_num_rows ( dbCursor *cursor )
int db_copy_table ()
int db_copy_table_by_ints ()
int db_copy_table_select ()
int db_copy_table_where ()
int db_close_database_shutdown_driver ()
int db_start_driver_open_database ()
int db_delete_table ()
int db_d_list_databases (void)
int db_driver ()
GRASS Development Team: http://grass.osgeo.org (preferably developers mailing list)
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. http://www.ing.unitn.it/~grass/proceedings/proceedings/pdfs/Blazek_Radim.pdf
GRASS 6 Vector Architecture: GRASS 6 Vector Architecture
Last change: