26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
import os
|
|
import json
|
|
from supabase import create_client, Client
|
|
|
|
url: str = "https://ruthqdjqcvazlregemdb.supabase.co"
|
|
key: str = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJ1dGhxZGpxY3ZhemxyZWdlbWRiIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTk0MTA2NTEsImV4cCI6MjA3NDk4NjY1MX0.peoFylhJQeMbPDze_6VTfbJUGqvaUCFsIH-9A0Aa3EM"
|
|
supabase: Client = create_client(url, key)
|
|
|
|
def lambda_handler(event, context):
|
|
if event['Records'][0]['eventName'] == 'INSERT':
|
|
new_item = event['Records'][0]['dynamodb']['NewImage']
|
|
response = (
|
|
supabase.table("cctv-people")
|
|
.insert({
|
|
'camera_id': new_item['camera_id']['S'],
|
|
'label_id': new_item['label_id']['S'],
|
|
'detect_timestamp': new_item['detect_timestamp']['S'],
|
|
'frame_timestamp': new_item['frame_timestamp']['S'],
|
|
'frame_url': new_item['frame_url']['S'],
|
|
'label_name': new_item['label_name']['S'],
|
|
'confidence': new_item['confidence']['N'],
|
|
'rekognition_response': json.loads(new_item['rekognition_response']['S'])
|
|
})
|
|
.execute()
|
|
)
|
|
print(response) |