Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit acf4cdc

Browse filesBrowse files
macboy012methane
authored andcommitted
Add 'auth_plugin' option (PyMySQL#389)
1 parent 17045e8 commit acf4cdc
Copy full SHA for acf4cdc

File tree

Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed

‎MySQLdb/_mysql.c

Copy file name to clipboardExpand all lines: MySQLdb/_mysql.c
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ _mysql_ConnectionObject_Initialize(
398398
"client_flag", "ssl",
399399
"local_infile",
400400
"read_timeout", "write_timeout", "charset",
401+
"auth_plugin",
401402
NULL } ;
402403
int connect_timeout = 0;
403404
int read_timeout = 0;
@@ -406,13 +407,14 @@ _mysql_ConnectionObject_Initialize(
406407
char *init_command=NULL,
407408
*read_default_file=NULL,
408409
*read_default_group=NULL,
409-
*charset=NULL;
410+
*charset=NULL,
411+
*auth_plugin=NULL;
410412

411413
self->converter = NULL;
412414
self->open = 0;
413415

414416
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
415-
"|ssssisOiiisssiOiiis:connect",
417+
"|ssssisOiiisssiOiiiss:connect",
416418
kwlist,
417419
&host, &user, &passwd, &db,
418420
&port, &unix_socket, &conv,
@@ -424,7 +426,8 @@ _mysql_ConnectionObject_Initialize(
424426
&local_infile,
425427
&read_timeout,
426428
&write_timeout,
427-
&charset
429+
&charset,
430+
&auth_plugin
428431
))
429432
return -1;
430433

@@ -491,6 +494,9 @@ _mysql_ConnectionObject_Initialize(
491494
if (charset) {
492495
mysql_options(&(self->connection), MYSQL_SET_CHARSET_NAME, charset);
493496
}
497+
if (auth_plugin) {
498+
mysql_options(&(self->connection), MYSQL_DEFAULT_AUTH, auth_plugin);
499+
}
494500

495501
conn = mysql_real_connect(&(self->connection), host, user, passwd, db,
496502
port, unix_socket, client_flag);

‎MySQLdb/connections.py

Copy file name to clipboardExpand all lines: MySQLdb/connections.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ class object, used to create cursors (keyword only)
8686
On Python 2, this option changes default value of `use_unicode`
8787
option from False to True.
8888
89+
:param str auth_plugin:
90+
If supplied, the connection default authentication plugin will be
91+
changed to this value. Example values:
92+
`mysql_native_password` or `caching_sha2_password`
93+
8994
:param str sql_mode:
9095
If supplied, the session SQL mode will be changed to this
9196
setting.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.