Add IF EXISTS clause to DROP USER statement (#309)

This commit is contained in:
Andrew Klychkov 2022-03-15 17:43:09 +03:00 committed by GitHub
parent b0de252ce2
commit 59d411ac82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -704,7 +704,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 Exception:
cursor.execute("DROP USER %s@%s", (user, hostname))
return True