Data import

Updated at:

This topic describes methods to speed up data import for large datasets or data with complex properties.

Import methods

Graph Database (GDB) supports the following three import methods. For more information, see An introduction to data import.
  • Import data from Alibaba Cloud Object Storage Service (OSS).
  • Use DataWorks Data Integration to sync data to GDB.
  • Use DataX to import data to GDB.

Import order

When importing a large volume of data, divide the data into multiple import tasks. Import the vertex files first, and then import the edge files into Graph Database (GDB).

The code format is as follows:
  • Import a vertex file
    curl -u {username}:{password} -X POST \
      -H 'Content-Type: application/json' \
      http://{mygdb-endpoint}:{port}/loader -d '
      {
        "source" : "oss://{mybucket}/{vertex}.csv",
        "ramRoleArn" : "acs:ram::{my-uid}:role/aliyunserviceroleforgdb",
      }'
  • Import an edge file
    curl -u {username}:{password} -X POST \
      -H 'Content-Type: application/json' \
      http://{mygdb-endpoint}:{port}/loader -d '
      {
        "source" : "oss://{mybucket}/{edge}.csv",
        "ramRoleArn" : "acs:ram::{my-uid}:role/aliyunserviceroleforgdb",
      }' 
Note The following list describes the fields in the code that you must replace with actual values. For information about how to obtain the field values, see Import data from OSS to a Graph Database (GDB) instance.
  • {username}: Replace with the account of the Graph Database (GDB) instance.
  • {password}: Replace with the password for the GDB instance account.
  • {mygdb-endpoint}: Replace with the endpoint of the GDB instance.
  • {port}: Replace with the port number corresponding to the GDB instance endpoint.
  • {mybucket}: Replace with the name of the OSS bucket.
  • {my-uid}: Replace with your Alibaba Cloud account UID.
  • {vertex}: Replace with the vertex file name.
  • {edge}: Replace with the edge file name.
Example:
  • Import a vertex file
    curl -u gdb_account:******** -X POST \
      -H 'Content-Type: application/json' \
      http://gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com:8182/loader -d '
      {
        "source" : "oss://gdb-document-test/vertex.csv",
        "ramRoleArn" : "acs:ram::140692647406****:role/aliyunserviceroleforgdb",
      }'
  • Import an edge file
     curl -u gdb_account:******** -X POST \
      -H 'Content-Type: application/json' \
      http://gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com:8182/loader -d '
      {
        "source" : "oss://gdb-document-test/edge.csv",
        "ramRoleArn" : "acs:ram::140692647406****:role/aliyunserviceroleforgdb",
      }'

Split import

If a vertex or edge file contains many properties, split the file into multiple files based on the properties. Then, import the data from these files into Graph Database (GDB) sequentially.
Note During the import, the properties of a data record with an existing id are updated.
Example:
  • Before splitting
    | id | label  | prop1:int | prop2:int | prop3:int | prop4:int | prop5:int | prop6:int |
    | -- | ------ | --------- | --------- | --------- | --------- | --------- | --------- |
    | 1  | vertex | 1         |           |           |           |           |           |
    | 2  | vertex | 2         |           |           |           |           |           |
    | 3  | vertex | 3         |           |           |           |           |           |
    | 4  | vertex | 4         | 4         | 4         | 4         | 4         | 6         |
  • After splitting
    # File 1
    | id | label  | prop1:int | prop2:int | prop3:int | prop4:int | prop5:int | prop6:int |
    | -- | ------ | --------- | --------- | --------- | --------- | --------- | --------- |
    | 1  | vertex | 1         |           |           |           |           |           |
    | 2  | vertex | 2         |           |           |           |           |           |
    | 3  | vertex | 3         |           |           |           |           |           |
    # File 2
    | id | label  | prop1:int | prop2:int | prop3:int | prop4:int | prop5:int | prop6:int |
    | -- | ------ | --------- | --------- | --------- | --------- | --------- | --------- |
    | 4  | vertex | 4         | 4         | 4         | 4         | 4         | 6         |
                    

Migrate data from Neo4j to Graph Database GDB

GDB supports data migration from Neo4j. For more information, see Import Neo4j data to GDB.