How to connect to mysql server with SSL from a flask app

扶醉桌前 提交于 2019-11-29 14:14:06
Thomas N.

You can add theses informations in your URI like this :

app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://your-username:your-password@localhost/schema?ssl_key=MyCertFolder/client-key.pem&ssl_cert=MyCertFolder/client-cert.pem'

Or using the SQLAlchemy create_engine, take a look to this post

In case you need to use a Cloud-based MySQL service, this configuration will be slightly different. For example,

In Azure, it will be,

app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://your-username:your-password@localhost/your-schema?ssl_ca=BaltimoreCyberTrustRoot.crt.pem'

wherein, the file BaltimoreCyberTrustRoot.crt.pem can be downloaded from here.

Similarly, the solution for AWS is discussed here.

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