From 2e0dbef2969dc0ea033c754d407c2e0bf742ba26 Mon Sep 17 00:00:00 2001 From: Felix Hamme Date: Wed, 17 May 2023 10:35:17 +0200 Subject: [PATCH] connection arguments: use 'passwd' instead of 'password' with older drivers --- plugins/module_utils/mysql.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/mysql.py b/plugins/module_utils/mysql.py index 371918b..0a25c6c 100644 --- a/plugins/module_utils/mysql.py +++ b/plugins/module_utils/mysql.py @@ -144,18 +144,24 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='', if _mysql_cursor_param == 'cursor': # In case of PyMySQL driver: if mysql_driver.version_info[0] < 1: - # for PyMySQL < 1.0.0, use 'db' instead of 'database' + # for PyMySQL < 1.0.0, use 'db' instead of 'database' and 'passwd' instead of 'password' if 'database' in config: config['db'] = config['database'] del config['database'] + if 'password' in config: + config['passwd'] = config['password'] + del config['password'] db_connection = mysql_driver.connect(autocommit=autocommit, **config) else: # In case of MySQLdb driver if mysql_driver.version_info[0] < 2 and mysql_driver.version_info[1] < 1: - # for MySQLdb < 2.1.0, use 'db' instead of 'database' + # for MySQLdb < 2.1.0, use 'db' instead of 'database' and 'passwd' instead of 'password' if 'database' in config: config['db'] = config['database'] del config['database'] + if 'password' in config: + config['passwd'] = config['password'] + del config['password'] db_connection = mysql_driver.connect(**config) if autocommit: db_connection.autocommit(True)