Fix mysql.py logic related to 53326 (#61832)

(cherry picked from commit e4d4e49388)
pull/62157/head
Andrey Klychkov 5 years ago committed by Toshio Kuratomi
parent df4f0e4ec2
commit 307c8c6a49

@ -0,0 +1,2 @@
bugfixes:
- mysql - Fix ``mysql_connect`` function's logic related to the ``cursor_class`` keyword argument (https://github.com/ansible/ansible/pull/61832).

@ -84,7 +84,7 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
except Exception as e: except Exception as e:
module.fail_json(msg="unable to connect to database: %s" % to_native(e)) module.fail_json(msg="unable to connect to database: %s" % to_native(e))
if cursor_class is not None: if cursor_class == 'DictCursor':
return db_connection.cursor(**{_mysql_cursor_param: mysql_driver.cursors.DictCursor}) return db_connection.cursor(**{_mysql_cursor_param: mysql_driver.cursors.DictCursor})
else: else:
return db_connection.cursor() return db_connection.cursor()

@ -257,7 +257,8 @@ def main():
login_user = module.params["login_user"] login_user = module.params["login_user"]
try: try:
cursor = mysql_connect(module, login_user, login_password, config_file, ssl_cert, ssl_key, ssl_ca, None, 'mysql_driver.cursors.DictCursor', cursor = mysql_connect(module, login_user, login_password, config_file,
ssl_cert, ssl_key, ssl_ca, None, cursor_class='DictCursor',
connect_timeout=connect_timeout) connect_timeout=connect_timeout)
except Exception as e: except Exception as e:
if os.path.exists(config_file): if os.path.exists(config_file):

Loading…
Cancel
Save