diff --git a/changelogs/fragments/553_fix_connection_arguemnts_for_old_mysqldb_driver.yaml b/changelogs/fragments/553_fix_connection_arguemnts_for_old_mysqldb_driver.yaml new file mode 100644 index 0000000..d0f5316 --- /dev/null +++ b/changelogs/fragments/553_fix_connection_arguemnts_for_old_mysqldb_driver.yaml @@ -0,0 +1,2 @@ +bugfixes: + - mysql module utils - use the connection arguments ``db`` instead of ``database`` and ``passwd`` instead of ``password`` when running with MySQLdb < 2.0.0 (https://github.com/ansible-collections/community.mysql/pull/553). diff --git a/plugins/module_utils/mysql.py b/plugins/module_utils/mysql.py index 713aba8..b95d20d 100644 --- a/plugins/module_utils/mysql.py +++ b/plugins/module_utils/mysql.py @@ -154,7 +154,7 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='', 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: + if mysql_driver.version_info[0] < 2 or (mysql_driver.version_info[0] == 2 and mysql_driver.version_info[1] < 1): # for MySQLdb < 2.1.0, use 'db' instead of 'database' and 'passwd' instead of 'password' if 'database' in config: config['db'] = config['database']