Use app×
QUIZARD
QUIZARD
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
175 views
in Information Technology by (178k points)
How do I insert data into AWS RDS and DynamoDB?

Please log in or register to answer this question.

1 Answer

+1 vote
by (178k points)

AWS RDS (MySQL Example):

import pymysql

# Connect to the database
conn = pymysql.connect(
    host='your-rds-endpoint',
    user='username',
    password='password',
    database='your_database'
)

# Create a cursor object
cursor = conn.cursor()

# SQL query to insert data
insert_query = "INSERT INTO users (username, email) VALUES (%s, %s)"

# Data to insert
data = ('john_doe', '[email protected]')

# Execute the query
cursor.execute(insert_query, data)

# Commit changes
conn.commit()

# Close the connection
conn.close()
 

AWS DynamoDB Example:

import boto3

# Create a DynamoDB client
dynamodb = boto3.resource('dynamodb')

# Get the table
table = dynamodb.Table('users')

# Insert data into the table
table.put_item(
    Item={
        'id': 1,
        'username': 'john_doe',
        'email': '[email protected]'
    }
)

print("Data inserted successfully!")
 

Related questions

+1 vote
1 answer
+1 vote
1 answer
+1 vote
1 answer

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...