This code is missing the important part of making describe_statement request to actually see the results of your statement execution.
replied 3 years ago
Thank you for your comment. We'll review and update the Knowledge Center article as needed.
I am able to run the lambda against a serverless redshift cluster. The execute statement command works, but I am not able to see the returned result. result = client_redshift.execute_statement(Database= 'dev', SecretArn= secret_arn, Sql= query_str, ClusterIdentifier= cluster_id)
I am running Boto3 version 1.24.65
Logging the results end up blank. With this statement "logger.info('response', response)" I see this in CloudWatch:
[INFO] 2023-05-10T03:51:56.094Z a01a4549-5dc6-4ead-8060-c004b331f6ed response
The response object is never logged. And when trying to convert "result" to string with str(result) gives the following error:
[ERROR] TypeError: not all arguments converted during string formatting
But when I check the cluster via the AWS console, I see the new table was created. What needs to be done to be able to see the result of the query execution?
replied 3 years ago
Thank you for your comment. We'll review and update the Knowledge Center article as needed.
As mentioned you'd need something to get the result of the execute command. I have a snippet below that I did, but you also have to import the time library as the time it takes the command to run can vary:
statement_id = result['Id']
describe_statement = client_redshift.describe_statement (
Id = statement_id
)
while True:
describe_statement = client_redshift.describe_statement (Id = statement_id)
if (describe_statement["Status"] == "FINISHED"):
print("Query Status - " + describe_statement["Status"])
break;
else:
print("Query Status - " + describe_statement["Status"])
time.sleep(2)
statement_result = client_redshift.get_statement_result(
Id = statement_id
)
You can then take statement_result and pull out information you may need. For instance if you were running a SELECT query, you could see that by calling/printing statement_result["Records"]
replied 3 years ago
Thank you for your comment. We'll review and update the Knowledge Center article as needed.
This article was reviewed and updated on 2026-03-31.
Relevant content
asked 2 years ago
asked 4 years ago
- AWS OFFICIALUpdated a year ago

