diff --git a/changelogs/fragments/399-missing-import.yml b/changelogs/fragments/399-missing-import.yml new file mode 100644 index 00000000..94eefdf0 --- /dev/null +++ b/changelogs/fragments/399-missing-import.yml @@ -0,0 +1,2 @@ +bugfixes: +- postgresql_query - could crash under certain conditions because of a missing import to `psycopg2.extras` (https://github.com/ansible-collections/community.postgresql/issues/283). diff --git a/plugins/module_utils/postgres.py b/plugins/module_utils/postgres.py index 887c61db..6d7c725b 100644 --- a/plugins/module_utils/postgres.py +++ b/plugins/module_utils/postgres.py @@ -18,6 +18,7 @@ psycopg2 = None # This line needs for unit tests try: import psycopg2 + import psycopg2.extras HAS_PSYCOPG2 = True except ImportError: HAS_PSYCOPG2 = False