The principle here is that there much be network connectivity between the Notebook Instance and the DB Instance, and the security groups on the DB Instance should allow in-bound traffic from the Notebook Instance
One example of such as setup is
RDS DB Instance is VPC vpc-a and Subnet subnet-b.
SageMaker Notebook is launched in VPC vpc-a, Subnet subnet-b, with Security Group sg-c with DirectIntenetAccess "Disabled"
In the RDS DB Instance's Security Group rules, you can add an Inbound Rule to allow inbound traffic from the SageMaker Notebook security group "sg-c"
-- Type - Protocol - Port Range - Source
-- MYSQL/Aurora - TCP - 3306 - sg-c
! pip install mysql-connector import mysql.connector mydb = mysql.connector.connect( host="$RDS_ENDPOINT", user="$RDS_USERNAME", passwd="$RDS_PASSWORD" ) cursor = mydb.cursor() cursor.execute("SHOW DATABASES")
Thanks for using Amazon SageMaker and let us know if there's anything else we can help with!
Edited by: JaipreetS-AWS on May 6, 2019 3:04 PM
How to install Phyton package in Jupyter Notebook instance in SageMaker?Accepted Answerasked 2 years ago
How to connect a Sagemaker Notebook to Glue CatalogAccepted Answerasked 2 years ago
Which connection method when using SageMaker Notebook through VPC Interface Endpoint?Accepted AnswerEXPERTasked 4 years ago
SageMaker notebook instance in VPC failed to connect to local databaseAccepted Answerasked 4 years ago
Can't Import Modules In Sagemaker Jupyter Notebookasked 3 months ago
Data Wrangler: Data Flow: Export to S3 using Jupyter Notebookasked 2 months ago
Sagemaker Jupyter notebookAccepted Answerasked 2 years ago
Sagemaker Jupyter Studio Notebook public sharingAccepted Answerasked 5 months ago
SQL Server driver issue on notebook instance running on AWS SageMakerasked a month ago
Determining the "right" instance type running Jupyter notebook in Sagemaker when reading/writing a huge parquet file?asked 6 months ago