即使成功执行后,我的Lambda python函数仍返回null

时间:2019-02-19 04:39:51

标签: python amazon-web-services aws-lambda amazon-rds

是AWS服务和python的初学者,我在lambda中使用以下代码进行连接 RDS并在API网关中调用它 成功执行以下代码后,它将返回null。

#!/usr/bin/python
import sys

import logging

import pymysql

import json

rds_host="host"

name="name"

password="password"

db_name="DB"

port = 3306

def save_events(event):

     """

       This function fetches content from mysql RDS instance

      """

    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 exercise WHERE bid = '1'")

    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)

0 个答案:

没有答案