The pymssql library requires python 2.7 or greater so port the syntax of this file to use python3-style exception handling
This commit is contained in:
parent
e43e572770
commit
0d706d25b6
1 changed files with 7 additions and 5 deletions
|
@ -73,7 +73,9 @@ options:
|
||||||
notes:
|
notes:
|
||||||
- Requires the pymssql Python package on the remote host. For Ubuntu, this
|
- Requires the pymssql Python package on the remote host. For Ubuntu, this
|
||||||
is as easy as pip install pymssql (See M(pip).)
|
is as easy as pip install pymssql (See M(pip).)
|
||||||
requirements: [ pymssql ]
|
requirements:
|
||||||
|
- python >= 2.7
|
||||||
|
- pymssql
|
||||||
author: Vedit Firat Arig
|
author: Vedit Firat Arig
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -177,7 +179,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
conn = pymssql.connect(user=login_user, password=login_password, host=login_querystring, database='master')
|
conn = pymssql.connect(user=login_user, password=login_password, host=login_querystring, database='master')
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if "Unknown database" in str(e):
|
if "Unknown database" in str(e):
|
||||||
errno, errstr = e.args
|
errno, errstr = e.args
|
||||||
module.fail_json(msg="ERROR: %s %s" % (errno, errstr))
|
module.fail_json(msg="ERROR: %s %s" % (errno, errstr))
|
||||||
|
@ -191,7 +193,7 @@ def main():
|
||||||
if state == "absent":
|
if state == "absent":
|
||||||
try:
|
try:
|
||||||
changed = db_delete(conn, cursor, db)
|
changed = db_delete(conn, cursor, db)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg="error deleting database: " + str(e))
|
module.fail_json(msg="error deleting database: " + str(e))
|
||||||
elif state == "import":
|
elif state == "import":
|
||||||
conn.autocommit(autocommit)
|
conn.autocommit(autocommit)
|
||||||
|
@ -205,12 +207,12 @@ def main():
|
||||||
if state == "present":
|
if state == "present":
|
||||||
try:
|
try:
|
||||||
changed = db_create(conn, cursor, db)
|
changed = db_create(conn, cursor, db)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg="error creating database: " + str(e))
|
module.fail_json(msg="error creating database: " + str(e))
|
||||||
elif state == "import":
|
elif state == "import":
|
||||||
try:
|
try:
|
||||||
changed = db_create(conn, cursor, db)
|
changed = db_create(conn, cursor, db)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg="error creating database: " + str(e))
|
module.fail_json(msg="error creating database: " + str(e))
|
||||||
|
|
||||||
conn.autocommit(autocommit)
|
conn.autocommit(autocommit)
|
||||||
|
|
Loading…
Reference in a new issue