Flask-SQLAlchemy ssl-connection with AWS RDS error

陌路散爱 提交于 2019-12-05 21:51:41

I think that in your case the connection string is correct, you just need to use ssl_ca option and not ssl_cert:

SQLALCHEMY_DATABASE_URI = 'mysql://user:password@myrds.rds.amazonaws.com.rds.amazonaws.com/miro_dev?ssl_ca=rds-combined-ca-bundle.pem'
TheHandofTheKing

I was able to get this work by adding

?sslmode=verify-ca&sslrootcert=rds-combined-ca-bundle.pem

to the connection string.

This came from the postgresql docs here along with the aws docs.

You can change the sslmode to require if you do not care about verifying the rds. I downloaded the pem file from here.

I do this:

...
ssl_args = {'ssl': {'ca': 'YOUR_SSL_CERT_PATH'}}

db_url = 'mysql://{}:{}@{}/{}'.format(username, password, server, database)
engine = create_engine(db_url, connect_args=ssl_args, echo=False)
cnx = engine.connect()
df = pd.read_sql_table('table_name', cnx)

And I'd suggest to not input a path like follows:

~/...

but:

/home/YOUR_USER/...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!