Import data files using the curl command
Updated at:
This topic describes how to use the curl command to import data files from an Object Storage Service (OSS) bucket to a Graph Database (GDB) instance, view an import task, and cancel an import task.
Prerequisites
- A Graph Database (GDB) instance has been created. For more information, see Create a primary instance.Note If the bucket was created in the Object Storage Service console, make sure that the GDB instance and the bucket are in the same region.
- Data files have been uploaded to a bucket. For more information, see Upload data files using the OSS console or Upload data files using ossutil.
Procedure
- On a client, run the following command to import data files from an OSS bucket to a GDB instance.
curl -i -u <username>:<password> -X POST \ -H 'Content-Type: application/json' \ http://<mygdb-endpoint>:<port>/loader -d ' { "source" : "oss://<bucket>/air-routes/<filename>", "ramRoleArn" : "<arninfo>", }'Note<username>: Replace with the username of the GDB instance.<password>: Replace with the password for the GDB instance.<mygdb-endpoint>: Replace with the endpoint of the GDB instance (internal or public endpoint).<port>: Replace with the port number of the GDB instance endpoint (internal or public port).<bucket>: Replace with the name of the bucket that stores the data files.<filename>: Replace with the name of the data file to import.<arninfo>: Replace with the ARN of the AliyunServiceRoleForGDB role in your Alibaba Cloud account. For more information, see Obtain an ARN.- When you copy the command, do not add a space after the backslash (\).
Example:- Import a point file
curl -i -u gdb_account:******** -X POST \ -H 'Content-Type: application/json' \ http://gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com:****/loader -d ' { "source" : "oss://examplebucket/air-routes/air-routes-latest-nodes.csv", "ramRoleArn" : "acs:ram::140692647406****:role/aliyunserviceroleforgdb", }' - Import an edge file
curl -i -u gdb_account:******** -X POST \ -H 'Content-Type: application/json' \ http://gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com:****/loader -d ' { "source" : "oss://examplebucket/air-routes/air-routes-latest-edges.csv", "ramRoleArn" : "acs:ram::140692647406****:role/aliyunserviceroleforgdb", }'
A response similar to the following is returned. This indicates that the GDB import program has verified the parameters and returned the import task ID (loadId).{ "status" : "200 OK", "payload" : { "loadId" : "552617AF-4F1E-4CD8-9533-A2EC154688DC" } } - Use the import task ID to run the corresponding command to view the status of the import task or cancel the import task.
- View the status of the import task
curl -u <username>:<password> -X GET 'http://<mygdb-endpoint>:<port>/loader/<loadId>'Note<username>: Replace with the username of the GDB instance.<password>: Replace with the password for the GDB instance.<mygdb-endpoint>: Replace with the endpoint of the GDB instance (internal or public endpoint).<port>: Replace with the port number of the GDB instance endpoint (internal or public port).<loadId>: Replace with the import task ID returned in Step 1.
Example:curl -u gdb_account:******** -X GET 'http://gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com:****/loader/552617AF-4F1E-4CD8-9533-A2EC154688DC'If the response contains an error message, see List of error messages for more information.
- Cancel the import taskImportant
- If you cancel a task that is running in the background, the process is blocked until the task stops.
- Point and edge data that has already been imported to the GDB instance is not rolled back and remains in the instance.
curl -u <username>:<password> -X DELETE 'http://<mygdb-endpoint>:<port>/loader/<loadId>'Note<username>: Replace with the username of the GDB instance.<password>: Replace with the password for the GDB instance.<mygdb-endpoint>: Replace with the endpoint of the GDB instance (internal or public endpoint).<port>: Replace with the port number of the GDB instance endpoint (internal or public port).<loadId>: Replace with the import task ID returned in Step 1.
Example:curl -u gdb_account:******** -X DELETE 'http://gds-bp1t4x427r15331915****.graphdb.rds.aliyuncs.com:****/loader/552617AF-4F1E-4CD8-9533-A2EC154688DC'
- View the status of the import task
Is this page helpful?