

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Neptune 載入器範例
<a name="load-api-reference-load-examples"></a>

 此範例示範如何使用 Gremlin CSV 格式，使用 Neptune 載入器將資料載入 Neptune 圖形資料庫。請求會以 HTTP POST 請求的形式傳送至 Neptune 載入器端點，而請求內文包含指定資料來源、格式、IAM 角色和其他組態選項的必要參數。回應包含負載 ID，可用於追蹤資料載入程序的進度。

**Example 請求**  
以下是使用 `curl` 命令透過 HTTP POST 傳送的請求。它會以 Neptune CSV 格式載入一個檔案。如需詳細資訊，請參閱[Gremlin 載入資料格式](bulk-load-tutorial-format-gremlin.md)。  

```
aws neptunedata start-loader-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --source "s3://{{bucket-name}}/{{object-key-name}}" \
  --format "csv" \
  --iam-role-arn "{{ARN for the IAM role you are using}}" \
  --s3-bucket-region "{{region}}" \
  --no-fail-on-error \
  --parallelism "MEDIUM" \
  --no-update-single-cardinality-properties \
  --no-queue-request
```
如需詳細資訊，請參閱《 AWS CLI 命令參考》中的 [start-loader-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/start-loader-job.html)。

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.start_loader_job(
    source='s3://{{bucket-name}}/{{object-key-name}}',
    format='csv',
    iamRoleArn='{{ARN for the IAM role you are using}}',
    s3BucketRegion='{{region}}',
    failOnError=False,
    parallelism='MEDIUM',
    updateSingleCardinalityProperties=False,
    queueRequest=False
)

print(response)
```

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/loader \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "source" : "s3://{{bucket-name}}/{{object-key-name}}",
        "format" : "csv",
        "iamRoleArn" : "{{ARN for the IAM role you are using}}",
        "region" : "{{region}}",
        "failOnError" : "FALSE",
        "parallelism" : "MEDIUM",
        "updateSingleCardinalityProperties" : "FALSE",
        "queueRequest" : "FALSE"
      }'
```
此範例假設您的 AWS 登入資料已在您的環境中設定。將 {{us-east-1}} 取代為 Neptune 叢集的區域。

```
curl -X POST https://{{your-neptune-endpoint}}:{{port}}/loader \
  -H 'Content-Type: application/json' \
  -d '{
        "source" : "s3://{{bucket-name}}/{{object-key-name}}",
        "format" : "csv",
        "iamRoleArn" : "{{ARN for the IAM role you are using}}",
        "region" : "{{region}}",
        "failOnError" : "FALSE",
        "parallelism" : "MEDIUM",
        "updateSingleCardinalityProperties" : "FALSE",
        "queueRequest" : "FALSE"
      }'
```

**Example 回應**  

```
{
    "status" : "200 OK",
    "payload" : {
        "loadId" : "{{ef478d76-d9da-4d94-8ff1-08d9d4863aa5}}"
    }
}
```