I would like to connect to a MySQL database that requires ca-cert. I can do it with MySQLdb like below:
MySQLdb.connect(host = self.host,
port = self.port,
unix_socket = self.unix_socket,
user = self.user,
passwd = self.passwd,
db = self.db,
ssl = { 'cert': self.sslcert,
'key': self.sslkey,
'ca': self.sslca }
How do I do the same think in SQLAlchemy or SQLObject?
Thanks, peter
To use SSL certs with SQLAlchemy and MySQLdb, use the following python code:
SQLObject (untested):
create_engine() in SQLAlchemy has a
connect_args
parameter:According to their docs, SQLAlchemy's
create_engine
function takes a db url with the following format:dialect[+driver]://user:password@host/dbname[?key=value..]
meaning you could pass the ssl key, cert, and ca as key value pairs.