From b6ad472c7805b390c63755dedeb9d557a62392d5 Mon Sep 17 00:00:00 2001 From: betanummeric <40263343+betanummeric@users.noreply.github.com> Date: Tue, 23 May 2023 15:32:21 +0200 Subject: [PATCH] fix connection arguments for MySQLdb <2.0 !=1.0 (#553) * fix connection arguments for MySQLdb <2.0 !=1.0 * add changelog fragment --------- Co-authored-by: Felix Hamme --- .../553_fix_connection_arguemnts_for_old_mysqldb_driver.yaml | 2 ++ plugins/module_utils/mysql.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/553_fix_connection_arguemnts_for_old_mysqldb_driver.yaml 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 00000000..d0f53163 --- /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 713aba89..b95d20d0 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']