Automate Cassandra Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Cassandra ADO.NET Provider

Connect .NET applications with the Cassandra real-time NoSQL cloud database service. Use Apache Cassandra as the big data backend that powers your .NET applications.

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

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

Cmdlets or ADO.NET?

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

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

Set the Server, Port, and Database connection properties to connect to Cassandra. Additionally, to use internal authentication set the User and Password connection properties.


  1. Install the module:

    Install-Module CassandraCmdlets
  2. Connect:

    $cassandra = Connect-Cassandra -Database "$Database" -Port "$Port" -Server "$Server"
  3. Search for and retrieve data:

    $firstname = "Bob" $customer = Select-Cassandra -Connection $cassandra -Table "Customer" -Where "FirstName = `'$FirstName`'" $customer

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

    $customer = Invoke-Cassandra -Connection $cassandra -Query 'SELECT * FROM Customer WHERE FirstName = @FirstName' -Params @{'@FirstName'='Bob'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Cassandra.CassandraConnection("Database=MyCassandraDB;Port=7000;Server=;") $conn.Open()
  3. Instantiate the CassandraDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT City, TotalDue from Customer" $da= New-Object System.Data.CData.Cassandra.CassandraDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $ $_.totaldue }

Update Cassandra Data


Update-Cassandra -Connection $Cassandra -Columns @('City','TotalDue') -Values @('MyCity', 'MyTotalDue') -Table Customer -Id "MyId"


$cmd = New-Object System.Data.CData.Cassandra.CassandraCommand("UPDATE Customer SET FirstName='Bob' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.Cassandra.CassandraParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert Cassandra Data


Add-Cassandra -Connection $Cassandra -Table Customer -Columns @("City", "TotalDue") -Values @("MyCity", "MyTotalDue")


$cmd = New-Object System.Data.CData.Cassandra.CassandraCommand("INSERT INTO Customer (FirstName) VALUES (@myFirstName)", $conn) $cmd.Parameters.Add(new System.Data.CData.Cassandra.CassandraParameter("@myFirstName","Bob")) $cmd.ExecuteNonQuery()

Delete Cassandra Data


Remove-Cassandra -Connection $Cassandra -Table "Customer" -Id "MyId"


$cmd = New-Object System.Data.CData.Cassandra.CassandraCommand("DELETE FROM Customer WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.Cassandra.CassandraParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()