'How to save the result of the select in aws lambda
How to save the result of the select statment from Snowflake in AWS Lambda. I want to print the value but I don't know how. The goal is to return in print statment number 1
def run_query(conn, query):
cursor = conn.cursor()
cursor.execute(query)
cursor.close()
statement_6= "select 1"
number = run_query(conn,statement_6)
print(number)
Solution 1:[1]
Your code should never reach the print(number) statement. The code is more or less like an endless loop, because the run_query() method is recursively calling itself. Since there is no return statement, this will create an endless loop and never reach the print statement.
Since you provided no further information, I only can guess that you are using Python with Postgres and psycopg.
You could try this:
def run_query(conn, query):
cursor = conn.cursor()
cursor.execute(query)
for record in cursor:
print record
cursor.close()
Somewhere in your code (since you did not provide any I have to guess again), you need to run something like this:
run_query(conn, "select 1")
The important thing to remember is, that you can not call run_query in your run_query function.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jens |
