How to use Alembic with a SSL connection?

2019-09-16 19:23发布

问题:

I use Alembic to manage my migrations. My database is on AWS, and I want to connect it with SSL.

In my alembic.ini I have the lines

[production]
script_location = alembic_prod
sqlalchemy.url = mysql+pymysql://user:password@my-rds-host.eu-west-1.rds.amazonaws.com/mydatabase

Of course, it works if user have the permission to connect the base without SSL, but not otherwise.

How to require a SSL connection, and specify the certificate ?

回答1:

You first need the certificate bundle -

http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html#MySQL.Concepts.SSLSupport

You then would add the appropriate parameter to your URL like shown here -

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



标签: ssl alembic