@@ -102,6 +102,13 @@ class object, used to create cursors (keyword only)
102
102
:param int client_flag:
103
103
flags to use or 0 (see MySQL docs or constants/CLIENTS.py)
104
104
105
+ :param str ssl_mode
106
+ specify the security settings for connection to the server;
107
+ see the MySQL documentation for more details
108
+ (mysql_option(), MYSQL_OPT_SSL_MODE).
109
+ Only one of 'DISABLED', 'PREFERRED', 'REQUIRED',
110
+ 'VERIFY_CA', 'VERIFY_IDENTITY' can be specified.
111
+
105
112
:param dict ssl:
106
113
dictionary or mapping contains SSL connection parameters;
107
114
see the MySQL documentation for more details
@@ -123,7 +130,7 @@ class object, used to create cursors (keyword only)
123
130
There are a number of undocumented, non-standard methods. See the
124
131
documentation for the MySQL C API for some hints on what they do.
125
132
"""
126
- from MySQLdb .constants import CLIENT , FIELD_TYPE
133
+ from MySQLdb .constants import CLIENT , FIELD_TYPE , SSL_MODE
127
134
from MySQLdb .converters import conversions , _bytes_or_str
128
135
from weakref import proxy
129
136
@@ -162,6 +169,12 @@ class object, used to create cursors (keyword only)
162
169
163
170
kwargs2 ['client_flag' ] = client_flag
164
171
172
+ if 'ssl_mode' in kwargs :
173
+ if hasattr (SSL_MODE , kwargs ['ssl_mode' ]):
174
+ kwargs2 ['ssl_mode' ] = getattr (SSL_MODE , kwargs ['ssl_mode' ])
175
+ else :
176
+ raise NotSupportedError ('Unknown MySQL ssl_mode specification: %s' % kwargs ['ssl_mode' ])
177
+
165
178
# PEP-249 requires autocommit to be initially off
166
179
autocommit = kwargs2 .pop ('autocommit' , False )
167
180
0 commit comments