user204069
user204069

Reputation: 1081

neo4j importer - without using csv

I want to import to neo4j database without using csv files, ie If I have mysql resultset then I just dump it into neo4j and mark the processed records in mysql db as processed.

Relationship and indexing should be managed in memory without requiring csv files.

One way to do is to use .save method of spring template but that just take one entity at a time, I have millions of records and it will take very long that way.

Can I bulk insert using any API to neo4j DB.

Upvotes: 0

Views: 92

Answers (1)

William Lyon
William Lyon

Reputation: 8546

Check out the neo4j-csv-firehose project. From the readme:

neo4j-csv-firehose enables Neo4j’s LOAD CSV Cypher command to load other from other datasources as well. It provides on-the-fly conversion of the other datasource to csv - and can therefore act as input for LOAD CSV.

You can point csv-firehose at mysql and stream the results of a SQL statement (or contents of a table) in CSV format to LOAD CSV Cypher. This allows you to use the performant LOAD CSV Cypher for import without having to deal with exporting data into CSV from mysql.

For example, to connect to mysql and import the contents of a table named person into Neo4j:

load csv with headers from "http://localhost:7474/csv/jdbc?url=jdbc%3Amysql%3A%2F%2Flocalhost%2Fmydb&table=person&user=mydb&password=123" as line create (:Person {firstname: line.firstName, lastname: line.lastName});

More examples are described here.

Upvotes: 0

Related Questions