![]() |
VOOZH | about |
The CData Cmdlets Module for Databricks is a standard PowerShell module offering straightforward integration with Databricks. Below, you will find examples of using our Databricks Cmdlets with native PowerShell cmdlets.
Accessing and integrating live data from Databricks has never been easier with CData. Customers rely on CData connectivity to:
While many customers are using CData's solutions to migrate data from different systems into their Databricks data lakehouse, several customers use our live connectivity solutions to federate connectivity between their databases and Databricks. These customers are using SQL Server Linked Servers or Polybase to get live access to Databricks from within their existing RDBMs.
Read more about common Databricks use-cases and how CData's solutions help solve data problems in our blog: What is Databricks Used For? 6 Use Cases.
To connect to a Databricks cluster, set the properties as described below.
Note: The needed values can be found in your Databricks instance by navigating to Clusters, and selecting the desired cluster, and selecting the JDBC/ODBC tab under Advanced Options.
$conn = Connect-Databricks -Server "$Server" -Port "$Port" -TransportMode "$TransportMode" -HTTPPath "$HTTPPath" -UseSSL "$UseSSL" -User "$User" -Password "$Password"
Follow the steps below to retrieve data from the Customers table and pipe the result into to a CSV file:
Select-Databricks -Connection $conn -Table Customers | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myCustomersData.csv -NoTypeInformation
You will notice that we piped the results from Select-Databricks into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.
The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.The following line deletes any records that match the criteria:
Select-Databricks -Connection $conn -Table Customers -Where "Country = US" | Remove-Databricks
The cmdlets make data transformation easy as well as data cleansing. The following example loads data from a CSV file into Databricks, checking first whether a record already exists and needs to be updated instead of inserted.
Import-Csv -Path C:\MyCustomersUpdates.csv | %{
$record = Select-Databricks -Connection $Databricks -Table Customers -Where ("Id = `'"+$_.Id+"`'")
if($record){
Update-Databricks -Connection $databricks -Table Customers -Columns ("City","CompanyName") -Values ($_.City, $_.CompanyName) -Where ("Id = `'"+$_.Id+"`'")
}else{
Add-Databricks -Connection $databricks -Table Customers -Columns ("City","CompanyName") -Values ($_.City, $_.CompanyName)
}
}
As always, our goal is to simplify the way you connect to data. With cmdlets users can install a data module, set the connection properties, and start building. Download Cmdlets and start working with your data in PowerShell today!
Download a free trial of the Databricks Cmdlets to get started:
Download NowLearn more:
👁 Databricks IconAn easy-to-use set of PowerShell Cmdlets offering real-time access to Databricks. The Cmdlets allow users to easily read, write, update, and delete live data - just like working with SQL server.