mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-15 19:31:54 +08:00
Add 'auth_plugin' option (#389)
This commit is contained in:

committed by
Inada Naoki

parent
17045e8ed0
commit
acf4cdcf89
@ -398,6 +398,7 @@ _mysql_ConnectionObject_Initialize(
|
||||
"client_flag", "ssl",
|
||||
"local_infile",
|
||||
"read_timeout", "write_timeout", "charset",
|
||||
"auth_plugin",
|
||||
NULL } ;
|
||||
int connect_timeout = 0;
|
||||
int read_timeout = 0;
|
||||
@ -406,13 +407,14 @@ _mysql_ConnectionObject_Initialize(
|
||||
char *init_command=NULL,
|
||||
*read_default_file=NULL,
|
||||
*read_default_group=NULL,
|
||||
*charset=NULL;
|
||||
*charset=NULL,
|
||||
*auth_plugin=NULL;
|
||||
|
||||
self->converter = NULL;
|
||||
self->open = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"|ssssisOiiisssiOiiis:connect",
|
||||
"|ssssisOiiisssiOiiiss:connect",
|
||||
kwlist,
|
||||
&host, &user, &passwd, &db,
|
||||
&port, &unix_socket, &conv,
|
||||
@ -424,7 +426,8 @@ _mysql_ConnectionObject_Initialize(
|
||||
&local_infile,
|
||||
&read_timeout,
|
||||
&write_timeout,
|
||||
&charset
|
||||
&charset,
|
||||
&auth_plugin
|
||||
))
|
||||
return -1;
|
||||
|
||||
@ -491,6 +494,9 @@ _mysql_ConnectionObject_Initialize(
|
||||
if (charset) {
|
||||
mysql_options(&(self->connection), MYSQL_SET_CHARSET_NAME, charset);
|
||||
}
|
||||
if (auth_plugin) {
|
||||
mysql_options(&(self->connection), MYSQL_DEFAULT_AUTH, auth_plugin);
|
||||
}
|
||||
|
||||
conn = mysql_real_connect(&(self->connection), host, user, passwd, db,
|
||||
port, unix_socket, client_flag);
|
||||
|
@ -86,6 +86,11 @@ class Connection(_mysql.connection):
|
||||
On Python 2, this option changes default value of `use_unicode`
|
||||
option from False to True.
|
||||
|
||||
:param str auth_plugin:
|
||||
If supplied, the connection default authentication plugin will be
|
||||
changed to this value. Example values:
|
||||
`mysql_native_password` or `caching_sha2_password`
|
||||
|
||||
:param str sql_mode:
|
||||
If supplied, the session SQL mode will be changed to this
|
||||
setting.
|
||||
|
Reference in New Issue
Block a user