简体   繁体   中英

how to import data from sql to neo4j

I have developed a .net project which has a SQL database. I want to know is there any way, that I can import my SQL DB file into the neo4j database directly?

Chris Skardon is right, you might want to iron out the categories a little bit. Neo4j is not a graph layer on top of a relational database, it is a competing/complementary kind of database. While it's possible to imitate your relational schema in Neo4j, its probably not very useful, and you will likely have to do a some remodeling to benefit from using Neo4j.

If you decide you do want to transfer data from your SQL database to Neo4j, but prefer not to code the actual import yourself, here are some tips and tools to look at. (I apologize for the list being so Java-centric, but I haven't interacted with Neo4j from .NET yet––I'm sure someone else here can help.)

I would, however, humbly recommend writing as much of your own code as possible for interacting with Neo4j. Probably someone else has done it better (at least that's what I tend to find) but writing it yourself will greatly enhance your understanding of the database and APIs and you will get much better mileage when you really know how to drive.

I don't know of any way Neo4j can import SQL directly, you mention you're using LinqToSQL to read your DB currently, so I presume you also have a set of classes representing your data?

As far as I know, your best bet is to read the data in via your LinqToSQL code, and then push it into the Neo4j database. However you will want to make sure your code makes sense, for example, you say

rather than creating tables and data

Neo4j has no concept of tables, I would spend time experimenting with a limited subset of the data you have to see if it actually makes sense to spend any time migrating. You may/probably will find your current data objects don't make sense in a graph world...

In addition to jjaderberg answer here, you can use Talend Open Studio for Big Data to query SQL server and import the results to Neo4j graph directly without export it to .csv or spreadsheets first.
Here is a tutorial on how to use Talend with Neo4j: http://neo4j.com/blog/fun-with-music-neo4j-and-talend/
Note that he is using .csv, but you can easily use task tMSSqlInput as a data source instead, task [tNeo4jOutput] as destination for your data, and task [tNeo4jOutputRelationship] for graph relationships.

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