From accc9418183c26349b24613472bcb01137b66021 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Fri, 20 Aug 2021 12:51:33 +0530 Subject: [PATCH] Fixed no attribute '_asdict' error when connecting the database server. Fixes #6663 --- docs/en_US/release_notes_5_7.rst | 1 + web/pgadmin/utils/driver/psycopg2/cursor.py | 23 +++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/en_US/release_notes_5_7.rst b/docs/en_US/release_notes_5_7.rst index 770bb5f1a..1e9f27e53 100644 --- a/docs/en_US/release_notes_5_7.rst +++ b/docs/en_US/release_notes_5_7.rst @@ -20,5 +20,6 @@ Bug fixes | `Issue #6564 `_ - Fixed an issue where columns with sequences get altered unnecessarily with a schema diff tool. | `Issue #6572 `_ - Partially fixes the data output panel display issue. +| `Issue #6663 `_ - Fixed no attribute '_asdict' error when connecting the database server. | `Issue #6671 `_ - Fixed UnboundLocalError where local variable 'user_id' referenced before assignment. | `Issue #6682 `_ - Renamed 'Auto rollback?' to 'Auto rollback on error?'. diff --git a/web/pgadmin/utils/driver/psycopg2/cursor.py b/web/pgadmin/utils/driver/psycopg2/cursor.py index ca4feb48a..318223083 100644 --- a/web/pgadmin/utils/driver/psycopg2/cursor.py +++ b/web/pgadmin/utils/driver/psycopg2/cursor.py @@ -94,19 +94,16 @@ class _WrapperColumn(object): # exposed as items of the cursor.description sequence. # Before psycopg2 2.8 the description attribute was a sequence # of simple tuples or namedtuples. - if psycopg2.__version__.find('2.8') != -1: - ores = OrderedDict() - ores['name'] = self.orig_col.name - ores['type_code'] = self.orig_col.type_code - ores['display_size'] = self.orig_col.display_size - ores['internal_size'] = self.orig_col.internal_size - ores['precision'] = self.orig_col.precision - ores['scale'] = self.orig_col.scale - ores['null_ok'] = self.orig_col.null_ok - ores['table_oid'] = self.orig_col.table_oid - ores['table_column'] = self.orig_col.table_column - else: - ores = OrderedDict(self.orig_col._asdict()) + ores = OrderedDict() + ores['name'] = self.orig_col.name + ores['type_code'] = self.orig_col.type_code + ores['display_size'] = self.orig_col.display_size + ores['internal_size'] = self.orig_col.internal_size + ores['precision'] = self.orig_col.precision + ores['scale'] = self.orig_col.scale + ores['null_ok'] = self.orig_col.null_ok + ores['table_oid'] = self.orig_col.table_oid + ores['table_column'] = self.orig_col.table_column name = ores['name'] if self.dummy_name: