DataSource¶
-
class
previsionio.datasource.
DataSource
(_id, connector, name, path=None, database=None, table=None, request=None, 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 (
Connector
) – 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
- request (str, optional) – Direct SQL request to use with the connector to fetch data
-
classmethod
from_id
(_id)¶ 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
(all=False)¶ List all the available datasources in the current active [client] workspace.
Warning
Contrary to the parent
list()
function, this method returns actualDataSource
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
)
-
classmethod
new
(connector, name, path=None, database=None, table=None, bucket=None, request=None, gCloud=None)¶ Create a new datasource object on the platform.
Parameters: - connector (
Connector
) – 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
- request (str, optional) – Direct SQL request to use with the connector to fetch data
Returns: The registered datasource object in the current workspace
Return type: Raises: PrevisionException
– Any error while uploading data to the platform or parsing the resultException
– For any other unknown error
- connector (