Doubt regarding the way data from Lambda function is getting stored in DynamoDB

0

import json import boto3 from datetime import datetime, timedelta

dynamodb = boto3.resource('dynamodb') table = dynamodb.Table('Applications')

def convert_to_ist(gmt_time): ist_offset = timedelta(hours=5, minutes=30) # IST offset from GMT/UTC ist_time = gmt_time + ist_offset ist_date = ist_time.strftime("%d/%m/%Y") ist_time = ist_time.strftime("%H:%M:%S") return ist_date, ist_time

def lambda_handler(event, context): # Convert current time to IST now = datetime.utcnow() now_ist_date, now_ist_time = convert_to_ist(now)

# Extract the form data from the event
form_data = {
    'Date': now_ist_date,
    'Time': now_ist_time,
    'firstName': event['firstName'],
    'lastName': event['lastName'],
    'email': event['email'],
    'Phone Number': event['phone'],
    'position': event['position'],
    'department': event['department']
}

# Process file upload
if 'cv' in event:
    cv_file = event['cv']
    form_data['cv'] = cv_file.encode('utf-8')

# Store the form data in DynamoDB
table.put_item(Item=form_data)

# Construct the success message
message = f"Hello {event['firstName']}, Your application has been submitted successfully!"
return message

This is my lambda function code. The data in dynamodb is not getting stored in this order. Can the order of columns in dynamodb be changed?

asked a year ago287 views
1 Answer
2
Accepted Answer

Hi,

I'm assuming that you are referencing the order in which columns are shown in the Amazon DynamoDB console. Please understand that DynamoDB is a NoSQL database. It does not use the concept of columns. This is because each item (row) can have different data. The management console attempts to show the data in columns to make it easier for us humans to read. However, that does not mean that the data is stored in this order, it is just a representation to make it easier for users to understand.

When retrieving data from DynamoDB, you can request specific keys (for example Name), or you can receive a JSON object from which you can parse the necessary information based on the Key and Value.

profile pictureAWS
EXPERT
answered a year ago
profile picture
EXPERT
reviewed 5 months ago
profile picture
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions