Ready to get started?

Learn more about the CData ADO.NET Provider for DataRobot or download a free trial:

Download Now

Automate DataRobot Integration Tasks from PowerShell

Are you looking for a quick and easy way to access DataRobot data from PowerShell? We show how to use the Cmdlets for DataRobot and the CData ADO.NET Provider for DataRobot to connect to DataRobot data and synchronize, automate, download, and more.

The CData Cmdlets for DataRobot are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to DataRobot.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the DataRobot API, but also an SQL interface; this tutorial shows how to use both to retrieve DataRobot data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for DataRobot. To access DataRobot data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for DataRobot.

After obtaining the needed connection properties, accessing DataRobot data in PowerShell consists of three basic steps.

To connect to DataRobot, the following connection properties are required: User, Password, and PredictionInstance. DataRobotKey may also be required depending on your type of DataRobot predictions instance. If using the Predictions API, DataFile is required. The CSV DataFile should include a header row as the first row of the datafile. APIKey is not required, but can be supplied. If not supplied, the driver will handle obtaining an APIKey.

User, DataRobotKey, and APIKey are the credentials for the DataRobot account.

ProjectID, DataFile, and ModelId are the parameters for the project, dataset, and model type.

PowerShell

  1. Install the module:

    Install-Module DataRobotCmdlets
  2. Connect:

    $datarobot = Connect-DataRobot -PredictionInstance "$PredictionInstance" -DataFile "$DataFile" -DataRobotKey "$DataRobotKey" -User "$User" -Password "$Password"
  3. Search for and retrieve data:

    $id = "1" $predictions = Select-DataRobot -Connection $datarobot -Table "Predictions" -Where "Id = `'$Id`'" $predictions

    You can also use the Invoke-DataRobot cmdlet to execute SQL commands:

    $predictions = Invoke-DataRobot -Connection $datarobot -Query 'SELECT * FROM Predictions WHERE Id = @Id' -Params @{'@Id'='1'}

ADO.NET

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for DataRobot\lib\System.Data.CData.DataRobot.dll")
  2. Connect to DataRobot:

    $conn= New-Object System.Data.CData.DataRobot.DataRobotConnection("PredictionInstance=myinstance.orm.datarobot.com;DataFile=PATH\TO\input_file.csv;DataRobotKey=123-abc-456-def;User=username;Password=password;") $conn.Open()
  3. Instantiate the DataRobotDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, Prediction1Value from Predictions" $da= New-Object System.Data.CData.DataRobot.DataRobotDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.prediction1value }