Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
wiki:designimplementation:dataaccess [2014/04/10 16:58] marisa [Common Data Source Capabilities] |
wiki:designimplementation:dataaccess [2014/08/18 14:14] (current) marisa [DataSource] |
||
---|---|---|---|
Line 39: | Line 39: | ||
Each data source driver must have a unique identifier. This identifier is a string (//in capital letters//) with the data source type name and it is available through the method ''getType''. Examples of identifiers are: POSTGIS, OGR, GDAL, SQLITE, WFS, WCS, MYSQL, ORACLE, SHP, MICROSOFT_ACCESS. | Each data source driver must have a unique identifier. This identifier is a string (//in capital letters//) with the data source type name and it is available through the method ''getType''. Examples of identifiers are: POSTGIS, OGR, GDAL, SQLITE, WFS, WCS, MYSQL, ORACLE, SHP, MICROSOFT_ACCESS. | ||
- | A data source is also characterized by a set of parameters that can be used to set up an access channel to its underlying repository. This information is referred as the data source connection information. This information may be provided as an associative container (a set of key-value pairs) through the method ''setConnectionInfo'' or using a plain connection string through the method ''setConnectionStr''. The key-value pairs (kvp) may contain information about maximum number of accepted connections, user name and password required for establishing a connection, the url of a service or any other information needed by the data source to operate. The parameters are dependent on the data source driver. So, please, check the driver documentation for any additional information on the supported parameters. When using a plain string, the information is encoded by a set of key-value pairs separated by an equal sign and each pair is separated by the ampersand (''&'') and they must be URL encoded. For instance, in a PostGIS data source it is usual to use the following syntax: | + | A data source is also characterized by a set of parameters that can be used to set up an access channel to its underlying repository. This information is referred as the data source connection information. This information may be provided as an associative container (a set of key-value pairs) through the method ''setConnectionInfo''. The key-value pairs (kvp) may contain information about maximum number of accepted connections, user name and password required for establishing a connection, the url of a service or any other information needed by the data source to operate. The parameters are dependent on the data source driver. So, please, check the driver documentation for any additional information on the supported parameters. For instance, in a PostGIS data source it is usual to use the following syntax: |
<code cpp> | <code cpp> | ||
- | std::string connInfo = "host=atlas.dpi.inpe.br&port=5432&dbname=mydb&user=postgres&password=mypasswd&connect_timeout=20"; | + | std::map<std::string, std::string> connInfo; |
+ | pgisInfo["PG_HOST"] = "atlas.dpi.inpe.br" ; // or "localhost"; | ||
+ | pgisInfo["PG_PORT"] = "5433" ; | ||
+ | pgisInfo["PG_USER"] = "postgres"; | ||
+ | pgisInfo["PG_PASSWORD"] = "xxxxxxx"; | ||
+ | pgisInfo["PG_DB_NAME"] = "terralib4"; | ||
+ | pgisInfo["PG_CONNECT_TIMEOUT"] = "4"; | ||
+ | pgisInfo["PG_CONNECT_TIMEOUT"] = "4"; | ||
+ | pgisInfo["PG_CLIENT_ENCODING"] = "CP1252"; | ||
</code> | </code> | ||
For a WFS data source available at ''http://www.dpi.inpe.br/wfs'' the connection string could be: | For a WFS data source available at ''http://www.dpi.inpe.br/wfs'' the connection string could be: | ||
<code cpp> | <code cpp> | ||
- | std::string connInfo = "service=http%3A%2F%2Fwww.dpi.inpe.br%2Fwfs"; | + | std::map<std::string, std::string> connInfo; |
+ | connInfo["URI"] = "http://www.dpi.inpe.br/wfs"; | ||
</code> | </code> | ||
- | The method ''getConnectionInfo'' returns an associative container (set of key-value pairs) with the connection information. The same information is also available in an URL encoded string through the method ''getConnectionStr''. | + | The method ''getConnectionInfo'' returns an associative container (set of key-value pairs) with the connection information. |
Another useful information available in a data source is its known [[:wiki:designimplementation:dataaccess#common_data_source_capabilities|capabilities]]. The method ''getCapabilities'' returns all information about what the data source can perform. Here you will find if the data source implementation supports primary keys, foreign keys, if it can be used in a thread environment and much more information. There is a list of common key-value pairs that every data access driver must supply although each implementation can provide additional information. | Another useful information available in a data source is its known [[:wiki:designimplementation:dataaccess#common_data_source_capabilities|capabilities]]. The method ''getCapabilities'' returns all information about what the data source can perform. Here you will find if the data source implementation supports primary keys, foreign keys, if it can be used in a thread environment and much more information. There is a list of common key-value pairs that every data access driver must supply although each implementation can provide additional information. |