mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
Convert all databases modules to python3 and 2.4 syntax (#3688)
This commit is contained in:
parent
f7b29ba8fd
commit
09066f1518
6 changed files with 54 additions and 28 deletions
|
@ -109,7 +109,8 @@ def setvariable(cursor, mysqlvar, value):
|
|||
cursor.execute(query + "%s", (value,))
|
||||
cursor.fetchall()
|
||||
result = True
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
result = str(e)
|
||||
return result
|
||||
|
||||
|
@ -153,7 +154,8 @@ def main():
|
|||
try:
|
||||
cursor = mysql_connect(module, user, password, config_file, ssl_cert, ssl_key, ssl_ca, db,
|
||||
connect_timeout=connect_timeout)
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
if os.path.exists(config_file):
|
||||
module.fail_json(msg="unable to connect to database, check login_user and login_password are correct or %s has the credentials. Exception message: %s" % (config_file, e))
|
||||
else:
|
||||
|
@ -172,7 +174,8 @@ def main():
|
|||
module.exit_json(msg="Variable already set to requested value", changed=False)
|
||||
try:
|
||||
result = setvariable(cursor, mysqlvar, value_wanted)
|
||||
except SQLParseError, e:
|
||||
except SQLParseError:
|
||||
e = get_exception()
|
||||
result = str(e)
|
||||
if result is True:
|
||||
module.exit_json(msg="Variable change succeeded prev_value=%s" % value_actual, changed=True)
|
||||
|
@ -184,4 +187,4 @@ from ansible.module_utils.basic import *
|
|||
from ansible.module_utils.database import *
|
||||
from ansible.module_utils.mysql import *
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue