-
Notifications
You must be signed in to change notification settings - Fork 441
Added to pass ssl_mode in configuration. #347
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
Changes from 7 commits
b28e723
fd02b7d
35b74ce
53e19a7
73c4296
08680b1
e57c474
8335d70
09dc7e9
67deee2
bd87447
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -102,6 +102,13 @@ class object, used to create cursors (keyword only) | |||||
:param int client_flag: | ||||||
flags to use or 0 (see MySQL docs or constants/CLIENTS.py) | ||||||
|
||||||
:param str ssl_mode | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks |
||||||
specify the security settings for connection to the server; | ||||||
see the MySQL documentation for more details | ||||||
(mysql_option(), MYSQL_OPT_SSL_MODE). | ||||||
Only one of 'DISABLED', 'PREFERRED', 'REQUIRED', | ||||||
'VERIFY_CA', 'VERIFY_IDENTITY' can be specified. | ||||||
|
||||||
:param dict ssl: | ||||||
dictionary or mapping contains SSL connection parameters; | ||||||
see the MySQL documentation for more details | ||||||
|
@@ -123,7 +130,7 @@ class object, used to create cursors (keyword only) | |||||
There are a number of undocumented, non-standard methods. See the | ||||||
documentation for the MySQL C API for some hints on what they do. | ||||||
""" | ||||||
from MySQLdb.constants import CLIENT, FIELD_TYPE | ||||||
from MySQLdb.constants import CLIENT, FIELD_TYPE, SSL_MODE | ||||||
from MySQLdb.converters import conversions, _bytes_or_str | ||||||
from weakref import proxy | ||||||
|
||||||
|
@@ -162,6 +169,14 @@ class object, used to create cursors (keyword only) | |||||
|
||||||
kwargs2['client_flag'] = client_flag | ||||||
|
||||||
if 'ssl_mode' in kwargs: | ||||||
if not _mysql.get_have_enum_mysql_opt_ssl_mode(): | ||||||
raise NotSupportedError('Does not support ssl_mode specification: %s' % _mysql.get_client_info()) | ||||||
if hasattr(SSL_MODE, kwargs['ssl_mode']): | ||||||
kwargs2['ssl_mode'] = getattr(SSL_MODE, kwargs['ssl_mode']) | ||||||
else: | ||||||
raise NotSupportedError('Unknown MySQL ssl_mode specification: %s' % kwargs['ssl_mode']) | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement this block in C. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implemented error checking on the C lang side. |
||||||
# PEP-249 requires autocommit to be initially off | ||||||
autocommit = kwargs2.pop('autocommit', False) | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"""MySQL SSL_MODE Constants | ||
|
||
These constants are used to specify SSL_MODE. | ||
|
||
""" | ||
|
||
DISABLED = 1 | ||
PREFERRED = 2 | ||
REQUIRED = 3 | ||
VERIFY_CA = 4 | ||
VERIFY_IDENTITY = 5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__all__ = ['CR', 'FIELD_TYPE','CLIENT','ER','FLAG'] | ||
__all__ = ['CR', 'FIELD_TYPE','CLIENT','ER','FLAG','SSL_MODE'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,4 @@ py_modules: | |
MySQLdb.constants.ER | ||
MySQLdb.constants.FIELD_TYPE | ||
MySQLdb.constants.FLAG | ||
MySQLdb.constants.SSL_MODE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't add new API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.