Reputation: 63
I have an assignment to write queries in Neo4J, but the database provided is SAKILA.SQL.
How can I load it into Neo4j?
I've tried to find an answer for this, but had no luck!
Upvotes: 1
Views: 478
Reputation: 2128
So you need to import (i.e. run all those insert statements) into MySQL first and then export into CSV files that Neo4j can use.
In the example Michael posted we used PostgresSQL's 'COPY' command to export CSV files. In MySQL you have a slightly different command as described over here.
You'd have something like:
SELECT * from customer
INTO OUTFILE '/tmp/customers.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
And then in Neo4j you'd have a query like this:
LOAD CSV WITH HEADERS FROM 'file:/tmp/customers.csv' AS line
MERGE (c:Customer {id: c.id})
ON CREATE SET c.name = line.name
And so on.
You can then do a similar thing to extract your other tables and use the MERGE command to create appropriate relationships between the different nodes.
If you share all the MySQL import script we can show you how to do a more complete translation.
Upvotes: 1
Reputation: 41676
Perhaps you can share your sql?
Easiest would be to insert it into a relational database, dump the table contents as CSV and import the data into Neo4j using LOAD CSV. See: http://neo4j.com/developer/guide-importing-data-and-etl/
See: http://neo4j.com/docs/stable/query-load-csv.html
For details on Cypher see: http://neo4j.com/developer/cypher/
Upvotes: 1