[Neo4j] Loading MySQL dump

Axel Morgner axel at morgner.de
Sat Dec 18 10:41:17 CET 2010


Hello Abhi,

you may have a look at the SQL Importer [1].

If you need more control over the import mechanism, and you have MySQL 
tables as XML (f.e. using mysqladmin export), you may use dom4j, Commons 
StringUtils and Java to parse it.

Within a Neo4j transaction, read the XML document, e.g. like this:

         SAXReader xmlReader = new SAXReader();
         try {

             Document xmlDoc = xmlReader.read(filename);

             Element root = xmlDoc.getRootElement();
             List<Element> rootChildren = root.elements();

             // Then iterate through child nodes
             for (Element e : rootChildren) {

                 // Create a node
                 Node node = graphDb.createNode();
                 String p = e.elementTextTrim(tagName);
                 if (StringUtils.isNotBlank(p)) { // optional
                     node.setProperty(propertyKey, p);
                 }

             [...]

         } catch (DocumentException ex) {
             [...]
         }

Depending of your data model (start here: [2], you may create a node 
structure with some major nodes (= tables) before adding sub nodes (= rows).

If you got large dumps to import, you may use the Neo4j BatchInserter [3].


Greetings

Axel

[1] http://wiki.neo4j.org/content/SQL_Importer
[2] http://wiki.neo4j.org/content/Domain_Modeling_Gallery
[3] http://wiki.neo4j.org/content/Batch_Insert

On 18.12.2010 05:22, Abhi wrote:
> Hello,
>
> I have a huge corpus of MySQL dump files of life sciences data which I would
> like to load into Neo4j. Is there an importer available for this? If not,
> what is the standard way to go about this problem? Is there any wiki or
> links for guidance?
>



More information about the User mailing list