-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing SSL certificates to mysql and postgresql #12
Comments
This is a good callout, I will work on it as soon as possible. Note that you can always pass the connection URL as well, including SSL details. There is a general problem with supporting different SQL dialects with the additional capabilities dbrequests offers compared to eg records, as it became apparent in #11. Please feel free to join the discussion there. |
The problem here is that the handling of SSL arguments is driver specific, ie for postgres, where a lot of very opinionated DBAPIs are out there, there is a difference for every driver used (eg between psycopg2 and pg8000). SQL alchemy chose to not offer an unified syntax for this and I tend to agree, since this would introduce driver specific code into the Database class, while the gain from it seems negligible? With #14 there will be a way to easily extend dbrequest with driver specific code, so I would vote for creating child classes implementing this for the different drivers. |
We should resolve this together with #27. What I would suggest is, that we allow the credentials object to comprise the connect_args, which are passed on to the sqlalchemy driver. E.G. creds = {
host='1.2.3.4',
...,
ssl='/path/to/ssl/cert',
other_arg=some_value
} from which we can build the url + the
I agree. If we construct the connect_args from the creds dict, we can leave it to the user to specify the appropriate settings, e.g. ssl for MySQL and (sslmode, sslrootcert) for PostgreSQL. Any objections? |
I think allowing the creds object to contain additional arguments that are passed on to the respective drivers is a good idea. It is what I first tried when I wanted to add the ssl certificate so it is an intuitive approach. |
To pass an ssl certiciat to pymysql one can use
where
DATABASE_CREDS['ssl']
contains a dictionary with the entry "ca": "<path to .pem file>For Postgresql(psycopg2) I have to pass different arguments to the Databse class:
I suggest using an "ssl" key in the database creds dictionary and depending on the
driver
entry it is passed on as a correctly formattedconnect_args
dict.The text was updated successfully, but these errors were encountered: