Fedora 29 / pgadmin4.3 Bug: ‘psycopg2.extensions.Column’ object has no attribute ‘_asdict’

There’s a bit of a lag in the Fedora RPMs from PostgreSQL’s repositories, so I thought I’d post this up in case anyone else out there runs into the error message in the subject of this post.

To fix it quickly (until the RPMs are updated), simply patch a single file (/usr/lib/python3.7/site-packages/pgadmin4-web/pgadmin/utils/driver/psycopg2/cursor.py) as follows:

1.  Right after the following lines (lines 18-19 in the file):

except ImportError:
    from ordereddict import OrderedDict


import psycopg2

2.  Replace the line (originally line 91 in the file):

        ores = OrderedDict(self.orig_col._asdict())

        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
            ores = OrderedDict(self.orig_col._asdict())

That’s it!  Careful about the line spacing; it’s python, so it’s quite sensitive to it.  If you use vim or some other python-aware editor, it should flag any incorrect spacing in your edits.

This entry was posted in Information Technology and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s