]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Added ssl_mode flag to mysqldb
authorGord Thompson <gord@gordthompson.com>
Fri, 13 Nov 2020 19:13:32 +0000 (14:13 -0500)
committerGord Thompson <gord@gordthompson.com>
Fri, 13 Nov 2020 19:59:31 +0000 (12:59 -0700)
Fixes: #5692
ssl_mode flag is added to mysqldb

### Description
mysqldb driver supports "ssl_mode" flag, which can be one of following values:
"DISABLED", "PREFERRED", "REQUIRED", "VERIFY_CA", "VERIFY_IDENTITY".
Depending on these values MySQL will behave accordingly to them.

So this flag has been added to the sqlaclhemy. So in case if TLS is not supported on the server, we can drop the connection right away.

Closes: #5693
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5693
Pull-request-sha: 94aed8b17d21da9a20be4b092f6a60b12f60b761

Change-Id: I7657b9c812d3a40ccacebbd8f4d5f20659d447c3

doc/build/changelog/unreleased_13/5692.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mysql/mysqldb.py
test/dialect/mysql/test_dialect.py

diff --git a/doc/build/changelog/unreleased_13/5692.rst b/doc/build/changelog/unreleased_13/5692.rst
new file mode 100644 (file)
index 0000000..475cafc
--- /dev/null
@@ -0,0 +1,6 @@
+.. change::
+    :tags: mysql, usecase
+    :tickets: 5692
+
+    Added ``ssl_mode`` dialect keyword to MySQL dialect for use with mysqldb.
+    Pull request courtesy Teodor Moroz.
index b20e061fb50e50fa8a2841823986e9d54da016f0..664c7a047429703d172a22458a1ab1ce808ae10e 100644 (file)
@@ -189,6 +189,7 @@ class MySQLDialect_mysqldb(MySQLDialect):
         util.coerce_kw_type(opts, "write_timeout", int)
         util.coerce_kw_type(opts, "client_flag", int)
         util.coerce_kw_type(opts, "local_infile", int)
+        util.coerce_kw_type(opts, "ssl_mode", str)
         # Note: using either of the below will cause all strings to be
         # returned as Unicode, both in raw SQL operations and with column
         # types like String and MSString.
index abd3a491ff1a8a1d533fa8e091cf0e3a6de954b3..d9aadb92d10fb5a892dc58f72594e2deddafdf4e 100644 (file)
@@ -141,6 +141,7 @@ class DialectTest(fixtures.TestBase):
             make_url(
                 "mysql://scott:tiger@localhost:3306/test"
                 "?ssl_ca=/ca.pem&ssl_cert=/cert.pem&ssl_key=/key.pem"
+                "&ssl_mode=REQUIRED"
             )
         )[1]
         # args that differ among mysqldb and oursql
@@ -156,6 +157,7 @@ class DialectTest(fixtures.TestBase):
                     "cert": "/cert.pem",
                     "key": "/key.pem",
                 },
+                "ssl_mode": "REQUIRED",
                 "host": "localhost",
                 "user": "scott",
                 "port": 3306,