Use the GdbLoader script to import data files

Updated at:

This topic describes how to use the GdbLoader script to import data files from a bucket in Object Storage Service (OSS) to a Graph Database (GDB) instance. This topic also describes how to view and cancel import tasks.

Prerequisites

Procedure

  1. Download and install the GdbLoader.py tool on the client.
    1. Run the following command to download the GDB toolkit.
      wget https://github.com/aliyun/alibabacloud-gdb-tools/archive/refs/heads/master.zip
    2. Run the following command to decompress the GDB toolkit.
      unzip master.zip
  2. Run the following command to add an import task.
    • Add a task to import a point file
      python GdbLoader.py --host <mygdb-endpoint> --port <port> --username <username> --password <password> --todo add_task --source oss://<bucket>/air-routes/<nodes.csv> --arn <arninfo>
      Note
      • <mygdb-endpoint>: Replace with the endpoint (internal or public) of the GDB instance.
      • <port>: Replace with the port number (internal or public) that corresponds to the endpoint of the GDB instance.
      • <username>: Replace with the account name of the GDB instance.
      • <password>: Replace with the password for the GDB instance account.
      • <bucket>: Replace with the name of the bucket that stores the data files.
      • <nodes.csv>: Replace with the name of the point file to import.
      • <arninfo>: Replace with the Alibaba Cloud Resource Name (ARN) of the AliyunServiceRoleForGDB role in your Alibaba Cloud account.
      Example:
      python GdbLoader.py --host gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com --port **** --username gdb_account --password ******** --todo add_task --source oss://examplebucket/air-routes/air-routes-latest-nodes.csv --arn acs:ram::140692647406****:role/aliyunserviceroleforgdb
    • Add a task to import an edge file
      python GdbLoader.py --host <mygdb-endpoint> --port <port> --username <username> --password <password> --todo add_task --source oss://<bucket>/air-routes/<edges.csv> --arn <arninfo>
      Note
      • <mygdb-endpoint>: Replace with the endpoint (internal or public) of the GDB instance.
      • <port>: Replace with the port number (internal or public) that corresponds to the endpoint of the GDB instance.
      • <username>: Replace with the account name of the GDB instance.
      • <password>: Replace with the password for the GDB instance account.
      • <bucket>: Replace with the name of the bucket that stores the data files.
      • <edges.csv>: Replace with the name of the edge file to import.
      • <arninfo>: Replace with the ARN of the AliyunServiceRoleForGDB role in your Alibaba Cloud account.
      Example:
      python GdbLoader.py --host gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com --port **** --username gdb_account --password ******** --todo add_task --source oss://examplebucket/air-routes/air-routes-latest-edges.csv --arn acs:ram::140692647406****:role/aliyunserviceroleforgdb
    A message similar to the following is returned. This message indicates that the GDB import program has verified the parameters and returned an import task ID (loadId
    {
      "status" : "200 OK",
      "payload" : {
          "loadId" : "552617AF-4F1E-4CD8-9533-A2EC154688DC"
      }
    }
  3. Use the import task ID to view the status of the import task or cancel the task.
    • View the status of an import task
      python GdbLoader.py --host <mygdb-endpoint> --port <port> --username <username> --password <password> --todo get_task --loaderId <loadId>
      Note
      • <mygdb-endpoint>: Replace with the endpoint (internal or public) of the GDB instance.
      • <port>: Replace with the port number (internal or public) that corresponds to the endpoint of the GDB instance.
      • <username>: Replace with the account name of the GDB instance.
      • <password>: Replace with the password for the GDB instance account.
      • <loadId>: Replace with the import task ID returned in step 2.
      Example:
      python GdbLoader.py --host gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com --port **** --username gdb_account --password ******* --todo get_task --loaderId 552617AF-4F1E-4CD8-9533-A2EC154688DC
    • Cancel an import task
      Important
      • If you cancel a task that is running in the background, the process is blocked until the task stops.
      • Point or edge data that has already been imported into the GDB instance is not rolled back. The data remains in the GDB instance.
      python GdbLoader.py --host <mygdb-endpoint> --port <port> --username <username> --password <password> --todo delete_task --loaderId <loadId>
      Note
      • <mygdb-endpoint>: Replace with the endpoint (internal or public) of the GDB instance.
      • <port>: Replace with the port number (internal or public) that corresponds to the endpoint of the GDB instance.
      • <username>: Replace with the account name of the GDB instance.
      • <password>: Replace with the password for the GDB instance account.
      • <loadId>: Replace with the import task ID returned in step 2.
      Example:
      python GdbLoader.py --host gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com --port **** --username gdb_account --password ******* --todo delete_task --loaderId 552617AF-4F1E-4CD8-9533-A2EC154688DC