I have a PostgreSQL backup .sql file and I want to import this file into Neo4j (database in graph). How do I?
I have a PostgreSQL backup .sql file and I want to import this file into Neo4j (database in graph). How do I?
@BrunoRB is correct, you will need at some point to create a Modelo Relacional <--> Grafo
mapping function of your data. This tutorial from Neo4j can help you .
By simplifying the above link, you will turn every record of every table in your database into a node in the Neo4j graph.
Given the following table:
Table "public.consumidor"
Column | Type | Modifiers
--------+-----------------------+---------------------------------------------------------
id | integer | not null default nextval('consumidor_id_seq'::regclass)
nome | character varying(40) |
What you need to do is export it to a .csv
file using the COPY
command from PostgreSQL:
COPY (SELECT * FROM consumidor) TO '/tmp/comsumidor.csv' WITH CSV header;
And create the equivalent nodes in Neo4j using the LOAD CSV
command of the Cypher language:
// Create customers
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:consumidor.csv" AS row
CREATE (:Consumidor {nome: row.nome, consumidorId: row.id});
There is no easy way. You will have to import this SQL into postgresql, create its equivalent structure in NEO4J and then write a data mapping code that will extract them from postgres and play in the equivalent NEO4J fields.