how we can set Pipeline for postgres database to neo4j database?

Viewed 404

I am planning to use Neo4j Graph database for website to show feed similar to linked in. I have tried the Neo4j in my local system it works but I am bit confuse in how I can migrate my PostgreSQL data to Neo4j and how to set pipeline so it can load data to neo4j regularly.

Can anyone suggest me good way to handle this?

1 Answers

In my case, I used the JDBC driver to connect from Neo4j to PostgresQL. You can find more information in the documentation. Basically, there is an APOC procedure that fetches data from Neo4j, which you can then store to Neo4j. Here is an example query:

WITH 'jdbc:postgresql://' + {sql_uri} + '/' + {sql_db} + '?user=' + {sql_username} +'&password='+{sql_password} as url,
'SELECT * FROM public.table WHERE foo = 'x')' as eracun_query
CALL apoc.load.jdbcParams(url, eracun_query,[]) yield row
CREATE (n:Node)
SET n += row

As you can see, you can define the SQL select statement to fetch any relevant data you might want from the postgreSQL database. You can then store its results with Cypher. If you are dealing with lots of data, I would suggest using apoc.periodic.iterate procedure for batching purposes.

Related