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
- You have created a destination Graph Database (GDB) instance. For more information, see Create a primary instance.Note If the bucket was created in the OSS console, make sure that the GDB instance and the bucket are in the same region.
- You have uploaded the data files to the bucket. For more information, see Upload data files using the OSS console or Upload data files using ossutil.
- You have installed Python on the client. For more information, see Installing Python.
Procedure
- Download and install the GdbLoader.py tool on the client.
- Run the following command to download the GDB toolkit.
wget https://github.com/aliyun/alibabacloud-gdb-tools/archive/refs/heads/master.zip - Run the following command to decompress the GDB toolkit.
unzip master.zip
- Run the following command to download the GDB toolkit.
- 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" } } - Add a task to import a point file
- 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 taskImportant
- 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
- View the status of an import task
Is this page helpful?