in Lambda python query DynamoDb does not return any data -
i wrote function return data table artist name joe. code below not resulting anything. first print. after nothing. not sure doing wrong.
from __future__ import print_function # python 2/3 compatibility import json import boto3 boto3.dynamodb.conditions import key, attr dynamodb = boto3.resource('dynamodb') table = dynamodb.table('music') def handler(event, context): print("joe's music") print(table.creation_date_time) response = table.query( keyconditionexpression=key('artist').eq('joe') ) in response['items']: print(i['artist'], ":", i['artist'])
here result getting.
start requestid: ...... version: $latest joe's music 2017-07-19 03:07:54.701000+00:00 end requestid: ...
quoting piece of code sample:
def handler(event,context): print("joe's music") print(table.creation_date_time) response = table.query( keyconditionexpression=key('artist').eq('joe') ) in response['items']: print(i['artist'], ":", i['artist'])
is code have, including indentation? recall indentation significant program structure in python. mean handler
consists of 2 print
statements, , table lookup code outside of that. make sense see results of 2 print
statements.
perhaps meant more this, indentation changed group table lookup , response handling code rest of handler
code.
def handler(event,context): print("joe's music") print(table.creation_date_time) response = table.query( keyconditionexpression=key('artist').eq('joe') ) in response['items']: print(i['artist'], ":", i['artist'])
additionally, perhaps want return
value, depending on needs. aws documentation on lambda function handler (python) has more details, including discussion of when return
value significant.
Comments
Post a Comment