DataSource

class previsionio.datasource.DataSource(_id, connector_id: str, name: str, path: str = None, database: str = None, table: str = None, request: str = None, gCloud: previsionio.connector.GCloud = None, **kwargs)

Bases: previsionio.api_resource.ApiResource, previsionio.api_resource.UniqueResourceMixin

A datasource to access a distant data pool and create or fetch data easily. This resource is linked to a Connector resource that represents the connection to the distant data source.

Parameters:
  • _id (str) – Unique id of the datasource
  • connector_id (str) – Reference to the associated connector (the resource to go through to get a data snapshot)
  • name (str) – Name of the datasource
  • path (str, optional) – Path to the file to fetch via the connector
  • database (str, optional) – Name of the database to fetch data from via the connector
  • table (str, optional) – Name of the table to fetch data from via the connector
  • bucket (str, optional) – Bucket of the file to fetch via the connector
  • request (str, optional) – Direct SQL request to use with the connector to fetch data
  • gCloud (GCloud, optional) – Type of google cloud service
delete()

Delete a datasource from the actual [client] workspace.

Raises:
  • PrevisionException – If the datasource does not exist
  • requests.exceptions.ConnectionError – Error processing the request
classmethod from_id(_id: str)

Get a datasource from the instance by its unique id.

Parameters:_id (str) – Unique id of the resource to retrieve
Returns:The fetched datasource
Return type:DataSource
Raises:PrevisionException – Any error while fetching data from the platform or parsing the result
classmethod list(project_id: str, all: bool = False)

List all the available datasources in the current active [client] workspace.

Warning

Contrary to the parent list() function, this method returns actual DataSource objects rather than plain dictionaries with the corresponding data.

Parameters:all (boolean, optional) – Whether to force the SDK to load all items of the given type (by calling the paginated API several times). Else, the query will only return the first page of result.
Returns:Fetched datasource objects
Return type:list(DataSource)