Search code examples
orientdborientdb-2.1

How to use the OrientDB ETL tool to import the entire database data?


I hope that once the import all data, Seemingly in extractor, JDBC query attributes can be only a single query.


Solution

  • The ETL tool allows you to import data from your RDBMS to OrientDB via a query that returns all of the table fields and converts them into a class. To migrate the data you have to create N json file containing the instructions to import individual tables with their relationships. A simple example of these two json, show how to import two tables, Table-A and Table-B with the relation B <- A.

    Create class from TABLE-A

    {
      "config": {
        "log": "debug"
      },
      "extractor" : {
        "jdbc": { "driver": "com.mysql.jdbc.Driver",
                  "url": "jdbc:mysql://localhost:3306/mysqldb",
                  "userName": "root",
                  "userPassword": "",
                  "query": "select * from TableA" }
      },
      "transformers" : [
       { "vertex": { "class": "TableA"} }
      ],
      "loader" : {
        "orientdb": {
          "dbURL": "plocal:/temp/databases/orientdb",
          "dbAutoCreate": true
        }
      }
    }
    

    Create class from TABLE-B and link table-b with table-a

    {
      "config": {
        "log": "debug"
      },
      "extractor" : {
        "jdbc": { "driver": "com.mysql.jdbc.Driver",
                  "url": "jdbc:mysql://localhost:3306/mysqldb",
                  "userName": "root",
                  "userPassword": "",
                  "query": "select * from TableB" }
      },
     "transformers" : [
       { "vertex": { "class": "TableB"} },
               { "edge": { "class": "associate", "direction" : "in",
                            "joinFieldName": "idTableB",
                            "lookup":"TableA.idTableA"
                  }
            }
      ], 
      "loader" : {
        "orientdb": {
          "dbURL": "plocal:/temp/databases/orientdb",
          "dbAutoCreate": true
        }
      }
    }
    

    I hope will be of help.