Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 AWS
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
AWS SDK ExecuteGremlinQuery
で を使用する
次のサンプルコードは、ExecuteGremlinQuery
を使用する方法を説明しています。
- Java
-
- SDK for Java 2.x
-
注記
GitHub には、その他のリソースもあります。AWS コード例リポジトリ
で全く同じ例を見つけて、設定と実行の方法を確認してください。 /** * Executes a Gremlin PROFILE query using the provided NeptunedataClient. * * @param client The NeptunedataClient instance to be used for executing the Gremlin PROFILE query. */ private static void executeGremlinProfileQuery(NeptunedataClient client) { System.out.println("Executing Gremlin PROFILE query..."); ExecuteGremlinProfileQueryRequest request = ExecuteGremlinProfileQueryRequest.builder() .gremlinQuery("g.V().has('code', 'ANC')") .build(); ExecuteGremlinProfileQueryResponse response = client.executeGremlinProfileQuery(request); if (response.output() != null) { System.out.println("Query Profile Output:"); System.out.println(response.output()); } else { System.out.println("No output returned from the profile query."); } }
-
API の詳細については、AWS SDK for Java 2.x 「 API リファレンス」のExecuteGremlinQuery」を参照してください。
-
- Python
-
- SDK for Python (Boto3)
-
注記
GitHub には、その他のリソースもあります。AWS コード例リポジトリ
で全く同じ例を見つけて、設定と実行の方法を確認してください。 """ Running this example. ---------------------------------------------------------------------------------- VPC Networking Requirement: ---------------------------------------------------------------------------------- Amazon Neptune must be accessed from **within the same VPC** as the Neptune cluster. It does not expose a public endpoint, so this code must be executed from: - An **AWS Lambda function** configured to run inside the same VPC - An **EC2 instance** or **ECS task** running in the same VPC - A connected environment such as a **VPN**, **AWS Direct Connect**, or a **peered VPC** """ # Replace with your actual Neptune endpoint NEPTUNE_ENDPOINT = "https://[Specify-Your-Endpoint]:8182" def main(): """ Entry point of the program. Initializes the Neptune client and runs both EXPLAIN and PROFILE queries. """ config = Config(connect_timeout=10, read_timeout=30, retries={'max_attempts': 3}) neptune_client = boto3.client( "neptunedata", endpoint_url=NEPTUNE_ENDPOINT, config=config ) try: run_profile_query(neptune_client) except ClientError as e: print(f"Neptune error: {e.response['Error']['Message']}") except BotoCoreError as e: print(f"BotoCore error: {str(e)}") except Exception as e: print(f"Unexpected error: {str(e)}") def run_profile_query(neptune_client): """ Runs a PROFILE query on the Neptune graph database. """ print("Running Gremlin PROFILE query...") try: response = neptune_client.execute_gremlin_profile_query( gremlinQuery="g.V().has('code', 'ANC')" ) print("Profile Query Result:") output = response.get("output") if output: print(output.read().decode('utf-8')) else: print("No explain output returned.") except Exception as e: print(f"Failed to execute PROFILE query: {str(e)}") if __name__ == "__main__": main()
-
API の詳細については、 AWS SDK for Python (Boto3) API リファレンスのExecuteGremlinQuery」を参照してください。
-
ExecuteGremlinProfileQuery
ExecuteOpenCypherExplainQuery