RDS-data query to pandas dataframe

0 votes

I have a serverless Aurora DB on AWS RDS (with data api enabled) that I would like to query using the database resource and secret ARNs. The code to do this is shown below.

rds_data = boto3.client('rds-data', region_name='us-west-1')

response = rds_data.execute_statement(
            resourceArn='DATABASE_ARN',
            secretArn='DATABASE_SECRET',
            database='db',
            sql=query)

rds_data.close()

The response contains the returned records, but the column names are not shown and the format is interesting (see below).

'records': [[{'stringValue': 'name'}, {'stringValue': '5'}, {'stringValue': '3'}, {'stringValue': '1'}, {'stringValue': '2'}, {'stringValue': '4'}]]

I want to query the aurora database and then create a pandas dataframe. Is there a better way to do this? I looked at just using psycopg2 and creating a database connection, but I believe you need a user name and password. I would like to not go that route and instead authenticate using IAM.

Dec 28, 2022 in AWS by Tejashwini
• 3,820 points

edited 5 days ago 5 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP