mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-20 01:11:27 -07:00
Add IF EXISTS clause to DROP USER statement (#307)
* Add IF EXISTS clause to DROP USER statement * Add a changelog fragment * Fix exception
This commit is contained in:
parent
1f16e65dfc
commit
3a452faeb0
2 changed files with 6 additions and 1 deletions
|
@ -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 Exception:
|
||||
cursor.execute("DROP USER %s@%s", (user, hostname))
|
||||
|
||||
return True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue