read data from rds mysql in sagemaker

Viewed 426

Im new in AWS world. I have a rds mysql database. And i wanna read data from this db in sagemaker, but there is a problem. Actually on local I can read this data like this:

def readFromAWS():
    conn = pymysql.connect(host='MY-ENDPOINT', port=3306, user='MY-USERNAME', password='MY-PASSWORD', db='DB-NAME')

    sqlText = """SELECT * FROM DB-NAME.XXX order by ID"""

    df = pd.read_sql(sqlText, conn)
    conn.close()
    return df
df=readFromAWS()

And on local it works well. But in sagemaker this code is useless. I need some advice. Are there any other way to read this? Should i use other services to read this data in sagemaker? Can you give me some advice??

1 Answers

With SageMaker you can read directly data from Amazon S3, Amazon EFS or Amazon FSx for Lustre. You could import the data to S3 or try aws-data-wrangler which allows easy intergration with PostgreSQL, MySQL, SQLServer etc. Here is an example

Related