How to connect Django to a mysql database over an ssl connection?


Problem :

I'm trying to connect Django to a mysql database which is accessible through an ssl connection. How do I configure this?

My first guess would be setting the 'OPTIONS' property of the database definition. However, I can't find info on what possible options to use. The option 'ssl': '/map/to/ca-cert.pem' does not work.

The following command seems to work:

mysql -h url.to.host -u lizard -p --ssl-ca=./ca-cert.pem

Edit: Ok I'm looking at the python-mysqldb documentation... maybe I can find the answer there.



Solution :

Django uses the Python MySQLdb library to interface with MySQL. Looking at the MySQLdb connection documentation, it looks like the ssl option requires a dictionary argument. So this might work:

'OPTIONS': {'ssl': {'key': '/map/to/ca-cert.pem'}}

Mysql Tutorials

Mysql Howto..

How to force mySQL NOT to convert varchar to numeric in WHERE comparison

How to update value in MySQL when the stored version differs to the passed argument

How to optimize my query to get result faster?

how to make Mysqldatabase converter in c#

How to do nested sum in group by in optimized/one query in MYSQL?

How to set SSH proxy user in PhpStorm to connect to MySQL?

How Would I Allow Users To Search MySql Database With Php [closed]

PowerPoint slide to display data from MySql database? How?

How to get next record inside the mysql result dataset?

Error in encoding mysql -> How can I reconvert it to something else?

How to combine a column name into MySQL “LIKE” clause

MySQL database with list of URLs - how to check for broken links?

How to get the number of decimal positions of a mysql table column

GWT - Hibernate: How to display results from MySQL into GWT client

Show row values as columns to display in a gridview [duplicate]

How to Restore backup file(mysql) with java?

How to ORDER BY a SUM() in MySQL?

How to resolve this MySQL query?

How to convert DateTime to a number in MySQL?

How to avoid “There is already an open DataReader associated with this Connection which must be closed first.” in MySql/net connector?

How to save data in a diffrent format in MySQL database

How to optimize this complex MYSQL query?

How to find out the count of one column in multiple group by using MySQL?

How to correctly do CREATE INDEX with SQLite

Prevent AJAX chat from showing duplicate messages (Javascript, PHP, MySQL)

How do I set a MysQL variable (time_zone) from within doctrine / symfony?

how to filter repeated rows based on date in Mysql?

How to constuct a MySQL query which will return a flag, either returning y or n based on the rows in another table?

MySQL Database Design. How to use dates in a relational database?

How to insert a value using mysql query in DB for all the rows except few