diff --git a/web/pgadmin/utils/driver/psycopg2/connection.py b/web/pgadmin/utils/driver/psycopg2/connection.py index 42b16118..f42e8333 100644 --- a/web/pgadmin/utils/driver/psycopg2/connection.py +++ b/web/pgadmin/utils/driver/psycopg2/connection.py @@ -972,7 +972,6 @@ WHERE self.__notifies = [] self.execution_aborted = False cur.execute(query, params) - res = self._wait_timeout(cur.connection) except psycopg2.Error as pe: errmsg = self._formatted_exception_msg(pe, formatted_exception_msg) current_app.logger.error( @@ -1001,7 +1000,7 @@ WHERE self.__async_cursor = cur self.__async_query_id = query_id - return True, res + return True, 1 def execute_void(self, query, params=None, formatted_exception_msg=False): """ diff --git a/web/pgadmin/utils/driver/psycopg2/cursor.py b/web/pgadmin/utils/driver/psycopg2/cursor.py index d78ab4b0..1e9f545e 100644 --- a/web/pgadmin/utils/driver/psycopg2/cursor.py +++ b/web/pgadmin/utils/driver/psycopg2/cursor.py @@ -18,6 +18,8 @@ try: except ImportError: from ordereddict import OrderedDict +import psycopg2 + from psycopg2.extensions import cursor as _cursor, encodings from .encoding import configureDriverEncodings @@ -91,7 +93,25 @@ class _WrapperColumn(object): Generates an OrderedDict from the fields of the original objects with avoiding the duplicate name. """ - ores = OrderedDict(self.orig_col._asdict()) + + # In psycopg2 2.8, the description of one result column, + # 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()) + name = ores['name'] if self.dummy_name: ores['name'] = self.dummy_name