From b45b5994332a327a5aca912b583735f0abb23dec Mon Sep 17 00:00:00 2001 From: Timo Runge Date: Fri, 8 Mar 2019 09:21:56 +0100 Subject: [PATCH] Fix for "AttributeError: 'module' object has no attribute 'cursors'" (#49191) (#53445) * Fix for "AttributeError: 'module' object has no attribute 'cursors'" (#49191) (#1) * Fix for "AttributeError: 'module' object has no attribute 'cursors'" (#49191) * Adding changelog fragment for issue #49191 and the following PR. * Update lib/ansible/module_utils/mysql.py Co-Authored-By: timorunge --- ...dule_utils_mysql-unexpected-keyword-argument-cursorclass.yml | 2 ++ lib/ansible/module_utils/mysql.py | 1 + 2 files changed, 3 insertions(+) create mode 100644 changelogs/fragments/49191-module_utils_mysql-unexpected-keyword-argument-cursorclass.yml diff --git a/changelogs/fragments/49191-module_utils_mysql-unexpected-keyword-argument-cursorclass.yml b/changelogs/fragments/49191-module_utils_mysql-unexpected-keyword-argument-cursorclass.yml new file mode 100644 index 0000000000..01139d4f39 --- /dev/null +++ b/changelogs/fragments/49191-module_utils_mysql-unexpected-keyword-argument-cursorclass.yml @@ -0,0 +1,2 @@ +bugfixes: +- mysql - MySQLdb doesn't import the cursors module for its own purposes so it has to be imported in MySQL module utilities before it can be used in dependent modules like the proxysql module family. diff --git a/lib/ansible/module_utils/mysql.py b/lib/ansible/module_utils/mysql.py index 8237efc10d..fab1bb27bb 100644 --- a/lib/ansible/module_utils/mysql.py +++ b/lib/ansible/module_utils/mysql.py @@ -35,6 +35,7 @@ try: except ImportError: try: import MySQLdb as mysql_driver + import MySQLdb.cursors _mysql_cursor_param = 'cursorclass' except ImportError: mysql_driver = None