Use GetQueryResults
with an AWS SDK
The following code examples show how to use GetQueryResults
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code example:
- JavaScript
-
- SDK for JavaScript (v3)
-
/**
* Simple wrapper for the GetQueryResultsCommand.
* @param {string} queryId
*/
_getQueryResults(queryId) {
return this.client.send(new GetQueryResultsCommand({ queryId }));
}
- Python
-
- SDK for Python (Boto3)
-
def _wait_for_query_results(self, client, query_id):
"""
Waits for the query to complete and retrieves the results.
:param query_id: The ID of the initiated query.
:type query_id: str
:return: A list containing the results of the query.
:rtype: list
"""
while True:
time.sleep(1)
results = client.get_query_results(queryId=query_id)
if results["status"] in [
"Complete",
"Failed",
"Cancelled",
"Timeout",
"Unknown",
]:
return results.get("results", [])
For a complete list of AWS SDK developer guides and code examples, see
Using CloudWatch Logs with an AWS SDK.
This topic also includes information about getting started and details about previous SDK versions.