我是python编程的初学者,试图将一个lambda函数的列表调用到另一个lambda函数中。
我使用了boto3
客户端,以下是Lambda1的代码:
import sys
import logging
import pymysql
import json
rds_host="host"
name="name"
password="pass"
db_name="DB"
port = 3306
def save_events(event):
result = []
conn = pymysql.connect(rds_host, user=name, passwd=password, db=db_name,
connect_timeout=30)
with conn.cursor() as cur:
cur.execute("select * from bodyPart")
for row in cur:
result.append(list(row))
print ("Data from RDS...")
print (result)
cur.close()
print(json.dumps({'bodyParts':result}))
def lambda_handler(event, context):
save_events(event)
return result
下面是Lambda2的代码:
import sys
import logging
import pymysql
import boto3
rds_host="host"
name="name"
password="pass"
db_name="DB"
port = 3306
def save_events(event):
result1 = []
lambda_client = boto3.client('lambda')
def lambda_handler(event, context):
invoke_response =
lambda_client.invoke(FunctionName="GYM",InvocationType='RequestResponse')
return str(invoke_response)
现在在Lambda2中,我如何从lambda1中获取“结果”列表