View a markdown version of this page

명령줄 도구를 사용하여 Amazon Neptune에 액세스 - Amazon Neptune

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

명령줄 도구를 사용하여 Amazon Neptune에 액세스

curl 및와 같은 AWS CLI, AWS SDKs 및 HTTP 도구를 사용하여 Neptune DB 클러스터awscurl에 쿼리를 제출할 수 있습니다. 다음 섹션에서는 각 도구를 설정하고 기본 Gremlin 및 openCypher 쿼리를 실행하는 방법을 보여줍니다.

사용 AWS CLI

aws neptunedata 명령을 사용하면 Gremlin 및 openCypher 쿼리를 실행하고, 엔진 상태를 확인하고, 대량 로드를 관리하는 등의 작업을 수행할 수 있습니다. 전체 명령 참조는 AWS CLI 명령 참조neptunedata의 섹션을 참조하세요.

다음 예제에서는 기본 쿼리를 실행하는 방법을 보여줍니다.

Gremlin
aws neptunedata execute-gremlin-query \ --endpoint-url https://your-neptune-endpoint:port \ --region us-east-1 \ --gremlin-query "g.V().limit(1)"

자세한 내용은 AWS CLI 명령 참조의 execute-gremlin-query를 참조하세요.

openCypher
aws neptunedata execute-open-cypher-query \ --endpoint-url https://your-neptune-endpoint:port \ --region us-east-1 \ --open-cypher-query "MATCH (n) RETURN n LIMIT 1"

자세한 내용은 AWS CLI 명령 참조의 execute-open-cypher-query를 참조하세요.

AWS SDK 사용

AWS SDKs를 실행할 수 있습니다. 다음 Python 예제에서는 기본 쿼리를 실행하는 방법을 보여줍니다.

Gremlin
import boto3 import json from botocore.config import Config # Disable the client-side read timeout and retries so that # Neptune's server-side neptune_query_timeout controls query duration. client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.execute_gremlin_query( gremlinQuery='g.V().limit(1)', serializer='application/vnd.gremlin-v3.0+json;types=false' ) print(json.dumps(response['result'], indent=2))

다른 언어의 AWS SDK 예제는 섹션을 참조하세요AWS SDK.

openCypher
import boto3 import json from botocore.config import Config # Disable the client-side read timeout and retries so that # Neptune's server-side neptune_query_timeout controls query duration. client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.execute_open_cypher_query( openCypherQuery='MATCH (n) RETURN n LIMIT 1' ) print(json.dumps(response['results'], indent=2))

다른 언어의 AWS SDK 예제는 섹션을 참조하세요AWS SDK.

curlawscurl 사용

curl 명령줄 도구는 HTTP 요청을 Neptune 엔드포인트에 직접 제출합니다. IAM 인증이 활성화된 경우 요청에 서명하는 --aws-sigv4 옵션과 함께 awscurl 또는 curl 7.75.0 이상을 사용합니다. 자세한 내용은 임시 보안 인증 정보와 awscurl을 사용하여 IAM 인증이 활성화된 상태에서 DB 클러스터에 안전하게 연결 단원을 참조하십시오.

HTTPS curl 설정

HTTPS를 사용하여 연결하려면(대부분의 리전에서 Neptune이 요구하는 대로)에 적절한 인증서에 대한 액세스 권한이 curl 필요합니다. 인증서를 얻고 인증 기관(CA) 저장소로 포맷하는 방법에 대한 자세한 내용은 curl 설명서의 SSL 인증서 확인을 참조하세요.

CURL_CA_BUNDLE 환경 변수를 사용하여이 CA 인증서 스토어의 위치를 지정할 수 있습니다. Windows에서 curlcurl-ca-bundle.crt라는 파일에서 자동으로 이 인증서를 찾습니다. 먼저 curl.exe와 동일한 디렉터리에서 찾은 다음 경로의 다른 곳을 찾습니다. 자세한 내용은 SSL Certificate Verification을 참조하십시오.

curl이 적절한 인증서를 찾을 수 있어야 추가 파라미터 없이 HTTP 연결과 같이 HTTPS 연결을 처리할 수 있습니다. 이 설명서의 예제는 해당 시나리오를 기반으로 합니다.

도구에 대한 자세한 내용은 curl man 페이지Everything curl 책을 참조하세요.

쿼리 예제

다음 예제에서는 curl 및를 사용하여 기본 쿼리를 실행하는 방법을 보여줍니다awscurl.

Gremlin (awscurl)
awscurl https://your-neptune-endpoint:port/gremlin \ --region us-east-1 \ --service neptune-db \ -X POST \ -d '{"gremlin":"g.V().limit(1)"}'
Gremlin (curl)
curl -X POST \ -d '{"gremlin":"g.V().limit(1)"}' \ https://your-neptune-endpoint:port/gremlin
참고

일반은 클러스터에서 IAM 인증이 활성화되지 않은 경우에만 curl 작동합니다.

openCypher (awscurl)
awscurl https://your-neptune-endpoint:port/openCypher \ --region us-east-1 \ --service neptune-db \ -X POST \ -d "query=MATCH (n) RETURN n LIMIT 1"
openCypher (curl)
curl -X POST \ -d "query=MATCH (n) RETURN n LIMIT 1" \ https://your-neptune-endpoint:port/openCypher
참고

일반은 클러스터에서 IAM 인증이 활성화되지 않은 경우에만 curl 작동합니다.

자세한 Gremlin HTTP 예제는 섹션을 참조하세요HTTPS REST. 자세한 openCypher HTTP 예제는 섹션을 참조하세요HTTPS 엔드포인트.