From 8892aa2bf430f25be124b655cc12c975cd1bfbdc Mon Sep 17 00:00:00 2001 From: Johann Schmitz Date: Tue, 26 May 2015 16:13:40 +0200 Subject: [PATCH] Improved output of mysql_db plugin Show error number and error description on connect error to ease debugging. --- database/mysql/mysql_db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/mysql/mysql_db.py b/database/mysql/mysql_db.py index 05db6beb07f..b9d862b56ac 100644 --- a/database/mysql/mysql_db.py +++ b/database/mysql/mysql_db.py @@ -346,11 +346,11 @@ def main(): db_connection = MySQLdb.connect(host=module.params["login_host"], port=login_port, user=login_user, passwd=login_password, db=connect_to_db) cursor = db_connection.cursor() except Exception, e: + errno, errstr = e.args if "Unknown database" in str(e): - errno, errstr = e.args module.fail_json(msg="ERROR: %s %s" % (errno, errstr)) else: - module.fail_json(msg="unable to connect, check login credentials (login_user, and login_password, which can be defined in ~/.my.cnf), check that mysql socket exists and mysql server is running") + module.fail_json(msg="unable to connect, check login credentials (login_user, and login_password, which can be defined in ~/.my.cnf), check that mysql socket exists and mysql server is running (ERROR: %s %s)" % (errno, errstr)) changed = False if db_exists(cursor, db):