简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM