mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Convert all databases modules to python3 and 2.4 syntax (#3688)
This commit is contained in:
committed by
Matt Clay
parent
f7b29ba8fd
commit
09066f1518
@@ -573,7 +573,8 @@ def main():
|
||||
module.fail_json(msg='Python module "psycopg2" must be installed.')
|
||||
try:
|
||||
conn = Connection(p)
|
||||
except psycopg2.Error, e:
|
||||
except psycopg2.Error:
|
||||
e = get_exception()
|
||||
module.fail_json(msg='Could not connect to database: %s' % e)
|
||||
|
||||
try:
|
||||
@@ -613,11 +614,13 @@ def main():
|
||||
schema_qualifier=p.schema
|
||||
)
|
||||
|
||||
except Error, e:
|
||||
except Error:
|
||||
e = get_exception()
|
||||
conn.rollback()
|
||||
module.fail_json(msg=e.message)
|
||||
|
||||
except psycopg2.Error, e:
|
||||
except psycopg2.Error:
|
||||
e = get_exception()
|
||||
conn.rollback()
|
||||
# psycopg2 errors come in connection encoding, reencode
|
||||
msg = e.message.decode(conn.encoding).encode(sys.getdefaultencoding(),
|
||||
|
||||
Reference in New Issue
Block a user