How to perform initial batch import of CSV / MySQL data into neo4j database

I am considering replacing the MySQL database with the neo4j database. I am starting out with neo4j and would like to know how to batch paste my current MySQL data into the neo4j database so that I can experiment and start learning about neo4j.

relational database consists of four tables: Person, Organism, Story, Links. Links describe the relationship between the rows in the other three tables.

Links: ID, FromTable, FromID, ToTable, ToID, LinkType

Person: ID, property_2, property_1, etc.

Organism: ID, property_A, property_B, etc.

Story: ID, property_x, property_y

each identifier field is an automatically incrementing integer starting at 1 for each table

In case this is not obvious, the link between the person with ID 3 and the story with ID 42 will contain a line in the link table ID = auto-increment, FromTable = Person, FromID = 3, ToTable = Story, ToID = 42. Despite the fact that I use the terms "from" and "to", the actual links are not really "directed" in practice.

I looked at Michael Hunger batch-import , but it looks like it only works with one node table and one relationship table, while I am looking to import three different types of nodes and one list of relations between them.

I have neo4j and it works. Any advice to get me started will be very appreciated.

I am not familiar with Java, although I use Python and bash shell scripts. After the initial import, I will use the RESTful interface with Javascript.

+5
2

git. Michael Hunger batch-import, node CSV . :

, , , .

, , , :

nodes:

  • nodes newID type. , node
  • 3 node, .
  • INSERT INTO nodes Person, Organism, Story, type , . .

rels newID Links sql JOIN:

INSERT INTO rels
SELECT  
    n1.newID AS fromNodeID, 
    n2.newID AS toNodeID,
    L.LinkType,
    L.ID
FROM 
    Links L
LEFT JOIN 
    nodes n1 
    ON 
    L.fromID = n1.ID 
    AND 
    L.fromType = n1.type
LEFT JOIN 
    nodes n2 
    ON 
    L.toID = n2.ID 
    AND 
    L.toType = n2.type;

nodes rels .csv :

$java -server -Xmx4G -jar target/batch-import-jar-with-dependencies.jar target/graph.db nodes.csv rels.csv
+9

, python shell, , py2neo, geoff. , , .

, py2neo .

- , ,

+1

All Articles