long2ice / asyncmy

A fast asyncio MySQL/MariaDB driver with replication protocol support
https://github.com/long2ice/asyncmy
Apache License 2.0
230 stars 25 forks source link

Accept SSL parameter as dict #64

Closed iKlotho closed 1 year ago

iKlotho commented 1 year ago

Most MySQL libraries support SSL configuration via a dictionary containing mysql_ssl_set params. This way users don't have to create SSL context by hand.

Available keys are key, cert, ca, capath, cipher, verify_mode and check_hostname

ssl_params = {
    "ca": "~/ca-cert.pem",
    "key": "~/client-key.pem",
    "cert": "~/client-cert.pem"
}
conn = await connect(ssl=ssl_params)
long2ice commented 1 year ago

This will break previous version, what about provide another param? changelog update is required also. Thanks!

iKlotho commented 1 year ago

The ssl param still accepts SSLContext and I don't think it will break previous versions. But If you think it's better I can use another parameter (maybe call it ssl_args) as you suggest.

https://github.com/long2ice/asyncmy/blob/3616ffc94f847f814100d98cdfc96c08eab82351/asyncmy/connection.pyx#L300-L302 Also for the changelog should I add a new version called 0.2.9?

long2ice commented 1 year ago

OK, that's good. I missed it. And yes for 0.2.9