![]() |
VOOZH | about |
The CData Cmdlets for Neo4J are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Neo4J.
The Cmdlets are not only a PowerShell interface to Neo4J, but also an SQL interface; this tutorial shows how to use both to retrieve Neo4J data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Neo4J. To access Neo4J data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Neo4J.
Once you have acquired the necessary connection properties, accessing Neo4J data in PowerShell can be enabled in three steps.
To connect to Neo4j, set the following connection properties:
Install the module:
Install-Module Neo4jCmdlets
Connect:
$neo4j = Connect-Neo4j -Server "$Server" -Port "$Port" -User "$User" -Password "$Password"
Search for and retrieve data:
$categoryowner = "CData Software" $productcategory = Select-Neo4j -Connection $neo4j -Table "ProductCategory" -Where "CategoryOwner = `'$CategoryOwner`'" $productcategory
You can also use the Invoke-Neo4j cmdlet to execute SQL commands:
$productcategory = Invoke-Neo4j -Connection $neo4j -Query 'SELECT * FROM ProductCategory WHERE CategoryOwner = @CategoryOwner' -Params @{'@CategoryOwner'='CData Software'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Neo4J\lib\System.Data.CData.Neo4j.dll")
Connect to Neo4J:
$conn= New-Object System.Data.CData.Neo4j.Neo4jConnection("Server=localhost;Port=7474;User=my_user;Password=my_password;")
$conn.Open()
Instantiate the Neo4jDataAdapter, execute an SQL query, and output the results:
$sql="SELECT CategoryId, CategoryName from ProductCategory"
$da= New-Object System.Data.CData.Neo4j.Neo4jDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.categoryid $_.categoryname
}
Download a free trial of the Neo4J Data Provider to get started:
Download NowLearn more:
👁 Neo4J IconRapidly create and deploy powerful .NET applications that integrate with Neo4J.