Over a million developers have joined DZone.

Data Loading Neo4j Graphs From SQL Sources

DZone's Guide to

Data Loading Neo4j Graphs From SQL Sources

· Integration Zone
Free Resource

The Integration Zone is brought to you in partnership with Cloud Elements. What's below the surface of an API integration? Download The Definitive Guide to API Integrations to start building an API strategy.

Neo4j is a powerful graph database that can be used for analytics, recommendation engines, social graphs and many more applications. In the following example we demonstrate in a few steps how you can load Neo4j from your legacy relations SQL source. If you need to get the mule studio: http://www.mulesoft.org/download-mule-esb-community-edition

Create a new mule project, and in the Mule flow:

  1. trigger an event from a web page. The default is http://localhost;8080
  2.  It will do a database query, in my case a simple Select
  3. Inline image 1
    3. Insert the returned map into Neo4j

    Inline image 4

    4.There are 3 lines of script to print the result

    import org.mule.modules.neo4j.model.Node
    Node myNode = payload
    System.err.println “Created node with id: ” + myNode.getId()
    In my console, I see the map of data extracted and then a node with properties created in Neo4j. Inline image 5 Some misc bits ... the choice block is there in the front because a browser will make 2 calls:
    • the first is a real page request
    • the second asks for the page browser icon “/favicon.ico”
    So the choice block filters this out to ensure that there is only 1 call.

    A real world application would probably use a polling even and have and split database records, or use Neo4j's bulk upload. However, I hope this gives you a taste of how easy integration can be. 

Your API is not enough. Learn why (and how) leading SaaS providers are turning their products into platforms with API integration in the ebook, Build Platforms, Not Products from Cloud Elements.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}