

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Neptune 스트림 데이터 읽기
<a name="streams-using-reading"></a>

다음 예제에서는 속성 그래프 스트림 엔드포인트에서 레코드를 읽는 방법을 보여줍니다. AWS CLI AWS SDK for Python(Boto3), **awscurl**또는를 사용할 수 있습니다**curl**.

------
#### [ AWS CLI ]

```
aws neptunedata get-propertygraph-stream \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --iterator-type TRIM_HORIZON \
  --limit 10
```

스트림의 특정 위치에서 읽으려면 `--commit-num` 및 `--iterator-type` 파라미터를 사용합니다.

```
aws neptunedata get-propertygraph-stream \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --limit 10 \
  --commit-num 1 \
  --iterator-type AT_SEQUENCE_NUMBER
```

자세한 내용은 AWS CLI 명령 참조의 [get-propertygraph-stream](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/get-propertygraph-stream.html)을 참조하세요.

------
#### [ SDK (Python) ]

```
import boto3
import json
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    region_name='{{us-east-1}}',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=65)
)

response = client.get_propertygraph_stream(
    limit=10,
    iteratorType='TRIM_HORIZON'
)

print(json.dumps(response['records'], indent=2, default=str))
```

스트림을 페이지 매김하려면 응답`lastEventId`에서의 `commitNum` 및를 사용합니다`opNum`.

```
last_event = response['lastEventId']
next_response = client.get_propertygraph_stream(
    limit=10,
    commitNum=last_event['commitNum'],
    opNum=last_event['opNum'],
    iteratorType='AFTER_SEQUENCE_NUMBER'
)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/propertygraph/stream?limit=10 \
  --region {{us-east-1}} \
  --service neptune-db
```

**참고**  
이 예제에서는 자격 AWS 증명이 환경에 구성되어 있다고 가정합니다. {{us-east-1}}을 Neptune 클러스터의 리전으로 바꿉니다.

IAM 인증과 **awscurl** 함께를 사용하는 방법에 대한 자세한 내용은 섹션을 참조하세요[임시 보안 인증 정보와 `awscurl`을 사용하여 IAM 인증이 활성화된 상태에서 DB 클러스터에 안전하게 연결](iam-auth-connect-command-line.md#iam-auth-connect-awscurl).

------
#### [ curl ]

```
curl https://{{your-neptune-endpoint}}:{{port}}/propertygraph/stream?limit=10
```

**참고**  
SigV4 서명 **curl** 없이를 사용하면 Neptune 클러스터에서 IAM 인증이 비활성화된 경우에만 작동합니다. IAM 인증이 활성화된 경우 **awscurl** 또는를 AWS CLI 대신 사용합니다.

------

SPARQL 그래프의 경우 이전 예제`/sparql/stream`에서를 `/propertygraph/stream`로 바꿉니다. AWS CLI 또는 SDK를 사용하는 경우 `client.get_sparql_stream()` 대신 `get-sparql-stream` 또는를 사용합니다.

## 그래프 노트북에서 스트림 데이터 보기
<a name="streams-using-notebook"></a>

[Neptune 그래프 노트북을](graph-notebooks.md) 사용하는 경우 `%stream_viewer` 라인 매직은 코드를 작성하지 않고도 대화형으로 스트림 레코드를 탐색할 수 있는 시각적 인터페이스를 제공합니다. 노트북 셀에서 다음을 실행합니다.

```
%stream_viewer
```

선택적으로 쿼리 언어와 페이지 크기를 지정할 수 있습니다.

```
%stream_viewer sparql --limit 20
```

자세한 내용은 [`%stream_viewer` 라인 매직](notebooks-magics.md#notebooks-line-magics-stream-viewer) 단원을 참조하십시오.

**참고**  
`%stream_viewer` 매직은 엔진 버전 1.0.5.1 이하에서만 완전히 지원됩니다.