Datasource Type#

A datasource type is an object that represents a source of data. This can be a database (MongoDB, MySQL), file storage (Dropbox, Google Cloud Storage), or a generic protocol or API (FTP, HTTP).

Note

For the full list, retrieve all DatasourceType objects (see Retrieving a DatasourceType) or refer to the IBM documentation.

Datasource objects are used as arguments when creating Connection objects.

Note

To read more about connections see Connections.

The SDK provides functionality to interact with datasource types.

This includes operations such as:
  • Retrieving datasource types

Retrieving a DatasourceType#

In the UI, the list of all DatasourceType objects is displayed during creation of a Connection (see Creating a Connection).

Screenshot of the DataSource selection in the UI

A DatasourceType can be retrieved using the Platform.datasources property. You can also filter the returned datasource types based on attributes including environment, perspective, and product.

This property returns a DatasourceTypes object.

>>> # Return the first datasource type matching the given `name`
>>> platform.datasources.get(name='jdbc')
DatasourceType(name='jdbc')

>>> # Return the first datasource type matching the given `perspective`
>>> platform.datasources.get(perspective='wx')
DatasourceType(name='informix')

>>> # Return a list of all datasource types that match `perspective`
>>> platform.datasources.get_all(perspective='wx')
[DatasourceType(name='informix'), DatasourceType(name='postgresql-ibmcloud'), ...]

>>> # Return a list of all datasource types
>>> platform.datasources
[DatasourceType(name='informix'), DatasourceType(name='postgresql-ibmcloud'), ...]

Tip

For detailed information about parameters and values, refer to the Datasource Types section of https://cloud.ibm.com/apidocs/data-ai-common-core.

Retrieving a DatasourceType connection properties#

In the UI, available connection fields depend on the previously selected DatasourceType (see Retrieving a DatasourceType).

For example, a JDBC connection requires three parameters by default: JDBC Connection String, Username, and Password.

Screenshot of the JDBC DataSource arguments.

An HTTP connection, on the other hand, requires only one parameter by default: File URL.

Screenshot of the HTTP DataSource arguments.

In the SDK, to get all properties available for a DatasourceType object, use the DatasourceType.properties property, which returns a DatasourceTypeProperties object. Then you can call DatasourceTypeProperties.connection to retrieve all available connection properties.

>>> # Get a datasource object
>>> datasource = platform.datasources.get(name='informix')
>>> datasource
DatasourceType(name='informix')
>>> datasource.properties.connection
[DatasourceTypeProperty(...), DatasourceTypeProperty(...), ...]

>>> # You can get a list of all required properties
>>> required_properties = datasource.required_connection_properties
>>> required_properties
[DatasourceTypeProperty(name='host'), DatasourceTypeProperty(name='password'), ...]

>>> # Or get details about a property
>>> required_property_1 = required_properties[0]
>>> required_property_1
DatasourceTypeProperty(name='host')
>>> required_property_1.type
'string'
>>> required_property_1.label
'Hostname or IP address'