Add IF EXISTS clause to DROP USER statement

This commit is contained in:
Andrew Klychkov 2022-03-15 11:10:11 +01:00
commit 760554a0d1

View file

@ -368,7 +368,10 @@ def user_delete(cursor, user, host, host_all, check_mode):
hostnames = [host]
for hostname in hostnames:
cursor.execute("DROP USER %s@%s", (user, hostname))
try:
cursor.execute("DROP USER IF EXISTS %s@%s", (user, hostname))
except:
cursor.execute("DROP USER %s@%s", (user, hostname))
return True