Q:

How to extend `psycopg2.extras. DictCursor`? 

I want to use a python3-psycopg2 (2.5.4) cursor that can:
1) access query result in a dict-like manner
2) log every sql executed by this cursor with logging module automatically
I tried the following code, it didn't work, what did I do wrong?  I can extend psycopg2.extensions.cursor, but that would not allow me to do 1). 
class LoggingCursor(psycopg2.extras. DictCursor):
    def __init__(self, *args, **kwargs):  # it didn't work with or
        super().__init__(*args, **kwargs) # without these 2 lines

    def execute(self, sql, args=None):
        from beautiful import app
        # logger = blah blah
        logger.debug(self.mogrify(sql, args).decode())
        psycopg2.extensions.cursor.execute(self, sql, args)

cursor = db_conn.cursor(cursor_factory=LoggingCursor)

When I cursor.execute(some_sql), it gives me:
File "some_file.py", line 123, in some_function
  some_var = cursor.fetchone()
File "/usr/local/lib/python3.4/dist-packages/psycopg2/extras.py", line 63, in fetchone
  res = super(DictCursorBase, self).fetchone()
File "/usr/local/lib/python3.4/dist-packages/psycopg2/extras.py", line 139, in __init__
  self._index = cursor.index

AttributeError: 'LoggingCursor' object has no attribute 'index'

A:

How about changing
psycopg2.extensions.cursor.execute(self, sql, args)

to
super().execute(sql, args)

so that the base class execute() method is called?