我有一个简单的 lambda 函数,它打印一个事件,然后尝试将一行插入数据库。它运行时没有错误,但不执行所有代码。
event被打印,但该行永远不会被插入到表中。任何事情,甚至是我放在后面的打印语句都connection不会被执行。我猜测连接有问题,但据我所知,我无法判断问题出在哪里。某处还有更多日志吗?在 CloudWatch 中,我看到最后显示“任务在 3.00 秒后超时”
import boto3
import psycopg2
s3 = boto3.client('s3')
def insert_data(event=None, context=None):
print(event)
connection = psycopg2.connect(user="xxxx", password="xxxx",
host="xxxx", port="xx",
database="xxxx")
cursor = connection.cursor()
postgres_insert_query = "INSERT INTO dronedata (name,lat,long,other) VALUES ('img2','54','43','from lambda')"
cursor.execute(postgres_insert_query)
connection.commit()
count = cursor.rowcount
print(count, "Record inserted successfully into mobile table")
慕盖茨4494581
白猪掌柜的
相关分类