![]() |
VOOZH | about |
The CData Cmdlets for Phoenix are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Phoenix.
The Cmdlets are not only a PowerShell interface to Phoenix, but also an SQL interface; this tutorial shows how to use both to retrieve Phoenix data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Phoenix. To access Phoenix data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Phoenix.
Once you have acquired the necessary connection properties, accessing Phoenix data in PowerShell can be enabled in three steps.
Connect to Apache Phoenix via the Phoenix Query Server. Set the Server and Port (if different from the default port) properties to connect to Apache Phoenix. The Server property will typically be the host name or IP address of the server hosting Apache Phoenix.
By default, no authentication will be used (plain). If authentication is configured for your server, set AuthScheme to NEGOTIATE and set the User and Password properties (if necessary) to authenticate through Kerberos.
Install the module:
Install-Module ApachePhoenixCmdlets
Connect:
$apachephoenix = Connect-ApachePhoenix -Server "$Server" -Port "$Port"
Search for and retrieve data:
$id = "123456" $mytable = Select-ApachePhoenix -Connection $apachephoenix -Table "MyTable" -Where "Id = `'$Id`'" $mytable
You can also use the Invoke-ApachePhoenix cmdlet to execute SQL commands:
$mytable = Invoke-ApachePhoenix -Connection $apachephoenix -Query 'SELECT * FROM MyTable WHERE Id = @Id' -Params @{'@Id'='123456'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Phoenix\lib\System.Data.CData.ApachePhoenix.dll")
Connect to Phoenix:
$conn= New-Object System.Data.CData.ApachePhoenix.ApachePhoenixConnection("Server=localhost;Port=8765;")
$conn.Open()
Instantiate the ApachePhoenixDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, Column1 from MyTable"
$da= New-Object System.Data.CData.ApachePhoenix.ApachePhoenixDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.id $_.column1
}
Download a free trial of the Phoenix Data Provider to get started:
Download NowLearn more:
👁 Apache Phoenix IconRapidly create and deploy powerful .NET applications that integrate with HBase through Apache Phoenix.