Skip to content

Instantly share code, notes, and snippets.

@ktechmidas
Created March 22, 2017 08:00
Show Gist options
  • Save ktechmidas/ce4114403c5db0332d1002d18b680ed6 to your computer and use it in GitHub Desktop.
Save ktechmidas/ce4114403c5db0332d1002d18b680ed6 to your computer and use it in GitHub Desktop.
def check_mysql_user(self, user, password, host=None):
print '\nverifying password of user %s ... ' % user,
kwargs = dict(host=host or self.mysql_host,
port=self.mysql_port,
user=user,
passwd=password)
try:
conn = MySQLdb.connect(**kwargs)
except Exception, e:
pdb.set_trace()
if isinstance(e, MySQLdb.OperationalError):
raise InvalidAnswer('Failed to connect to mysql server using user "%s" and password "***": %s' \
% (user, e.args[1]))
else:
raise InvalidAnswer('Failed to connect to mysql server using user "%s" and password "***": %s' \
% (user, e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment