Exporter

class previsionio.exporter.Exporter(_id, connector_id: str, name: str, description: str = None, path: str = None, bucket: str = None, database: str = None, table: str = None, g_cloud: previsionio.connector.GCloud = None, write_mode: previsionio.exporter.ExporterWriteMode = <ExporterWriteMode.safe: 'safe'>, **kwargs)

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

An exporter to access a distant data pool and upload 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 exporter
  • connector_id (str) – Reference to the associated connector (the resource to go through to get a data snapshot)
  • name (str) – Name of the exporter
  • description (str, optional) – Description of the exporter
  • path (str, optional) – Path to the file to write on via the exporter
  • bucket (str, optional) – Bucket of the file to write on via the exporter
  • database (str, optional) – Name of the database to write on via the exporter
  • table (str, optional) – Name of the table to write on via the exporter
  • g_cloud (GCloud, optional) – Type of google cloud service
  • write_mode (ExporterWriteMode, optional) – Write mode
delete()

Delete an exporter from the actual [client] workspace.

Raises:
  • PrevisionException – If the exporter does not exist
  • requests.exceptions.ConnectionError – Error processing the request
export_dataset(dataset: previsionio.dataset.Dataset, wait_for_export: bool = False)

Upload a Dataset from the current active project using the exporter.

Parameters:
  • dataset (Dataset) – dataset to upload
  • wait_for_export (bool, optional) – Wether to wait until the export is complete or not
Returns:

The registered export object

Return type:

Export

export_file(file_path: str, encoding: str = None, separator: str = None, decimal: str = None, thousands: str = None, wait_for_export: bool = False, **kwargs)

Upload a CSV file using the exporter.

Parameters:
  • file_path (str) – Path of the file to upload
  • encoding (str, optional) – Encoding of the file to upload
  • separator (str, optional) – Separator of the file to upload
  • decimal (str, optional) – Decimal of the file to upload
  • thousands (str, optional) – Thousands of the file to upload
  • wait_for_export (bool, optional) – Wether to wait until the export is complete or not
Returns:

The registered export object

Return type:

Export

export_prediction(prediction: Union[previsionio.prediction.DeploymentPrediction, previsionio.prediction.ValidationPrediction], wait_for_export: bool = False)

Upload a DeploymentPrediction or a ValidationPrediction from the current active project using the exporter.

Parameters:
  • dataset (DeploymentPrediction`|:class:.ValidationPrediction`) – prediction to upload
  • wait_for_export (bool, optional) – Wether to wait until the export is complete or not
Returns:

The registered export object

Return type:

Export

classmethod from_id(_id: str)

Get an exporter from the instance by its unique id.

Parameters:_id (str) – Unique id of the exporter to retrieve
Returns:The fetched exporter
Return type:Exporter
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 exporters in the current active [client] workspace.

Parameters:
  • project_id (str) – Unique reference of the project id on the platform
  • 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:

The fetched exporter objects

Return type:

list(Exporter)

list_exports()

List all the available exports given the exporter id.

Returns:The fetched export objects
Return type:list(Export)
class previsionio.exporter.ExporterWriteMode

Bases: enum.Enum

Write mode for exporters.

append = 'append'

Append to existing table.

replace = 'replace'

Replace existing file/table.

safe = 'safe'

Fail if file already exists.

timestamp = 'timestamp'

Append timestamp to the output filename.