- 최신
- 최다 투표
- 가장 많은 댓글
Hi,
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
Sample Code:
! 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
관련 콘텐츠
- AWS 공식업데이트됨 2년 전