connect.c
Go to the documentation of this file.00001 #include <grass/gis.h>
00002 #include <grass/dbmi.h>
00003
00010 int db_set_connection(dbConnection * connection)
00011 {
00012
00013
00014 if (connection->driverName)
00015 G_setenv2("DB_DRIVER", connection->driverName, G_VAR_MAPSET);
00016
00017 if (connection->databaseName)
00018 G_setenv2("DB_DATABASE", connection->databaseName, G_VAR_MAPSET);
00019
00020 if (connection->schemaName)
00021 G_setenv2("DB_SCHEMA", connection->schemaName, G_VAR_MAPSET);
00022
00023 if (connection->group)
00024 G_setenv2("DB_GROUP", connection->group, G_VAR_MAPSET);
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 return DB_OK;
00041 }
00042
00049 int db_get_connection(dbConnection * connection)
00050 {
00051
00052
00053 connection->driverName = G__getenv2("DB_DRIVER", G_VAR_MAPSET);
00054 connection->databaseName = G__getenv2("DB_DATABASE", G_VAR_MAPSET);
00055 connection->schemaName = G__getenv2("DB_SCHEMA", G_VAR_MAPSET);
00056 connection->group = G__getenv2("DB_GROUP", G_VAR_MAPSET);
00057
00058
00059
00060
00061
00062
00063
00064
00065 return DB_OK;
00066 }