mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -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
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue