I need to pass in a custom argument to SQLAlchemy's create_engine function in order to SSL authorize my database connection with AWS RDS. here, here, and here it was recommended that I use SQLAlchemy's connect_args to pass in my custom keyword argument. I tried:
engine = create_engine(os.environ['DB_URI'], connect_args={'ssla':'amazon-rds-ca-cert.pem'})
However, I the following TypeError, which is the same error other posters said connect_args fixed for them:
TypeError: 'ssla' is an invalid keyword argument for this function
It seems like I'm doing this exactly right. I also tried passing the keyword arguments in the connection string:
mysql://name:password@localhost/test?sslca=amazon-rds-ca-cert.pem
And changing the names of the keyword arguments to exactly match the example in the sqlalchemy docs:
db = create_engine('mysql://name:password@localhost/test', connect_args = {'argument2':'bar'})
However, still no luck. It seems that the error is being thrown by MySQLdb in the error message, so perhaps it's an error there?
File "/Users/tobyweed/workspace/ftm/live-event-market/server/serverenv/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 411, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/Users/tobyweed/workspace/ftm/live-event-market/server/serverenv/lib/python2.7/site-packages/MySQLdb/__init__.py", line 86, in Connect
return Connection(*args, **kwargs)
File "/Users/tobyweed/workspace/ftm/live-event-market/server/serverenv/lib/python2.7/site-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
TypeError: 'ssla' is an invalid keyword argument for this function
However, I don't have MySQLdb installed, so it must be SQLAlchemy which is using it. I have the latest version of SQLAlchemy (1.2.8), so that can't be it.
Please help!