python - str() error when running AWS Lambda (converting uuid to string) w/ Dynamo DB -
i have tried converting uuid string in code below , error. regardless of whether or not declare str() separately uuid.uuid4() see code below:
__future__ import print_function decimal import * import boto3 import json locale import str import uuid def my_handler(event, context): description = event['description'] spot_id = uuid.uuid4() #unique identifier spot dynamodb = boto3.client('dynamodb') tablesinfo = "sinfo" dynamodb.put_item( tablename = tablesinfo, item = { 'spot_id':{'s' : str(spot_id)}, 'description': {'s' : description } ) return {'spot_id' : spot_id}
these errors receive:
{ "stacktrace": [ [ "/var/task/create_spot_test.py", 15, "my_handler", "'spot_id':{'s' : str(spot_id)}," ], [ "/usr/lib64/python2.7/locale.py", 303, "str", "return format(\"%.12g\", val)" ], [ "/usr/lib64/python2.7/locale.py", 196, "format", "return _format(percent, value, grouping, monetary, *additional)" ], [ "/usr/lib64/python2.7/locale.py", 202, "_format", "formatted = percent % value" ] ], "errortype": "typeerror", "errormessage": "float argument required, not uuid" }
from locale import str
not needed (was imported previous error)
also must first declare uuid = uuid.uuid4()
variable , declare variable converting string spot_id = str(uuid)
rather running str()
inline.
Comments
Post a Comment