Vernon Cole - 2014-04-22

As required by PEP-249, the information you request is stored as part of the cursor's .description attribute:

Cursor Objects should respond to the following methods and attributes.
Cursor attributes


This read-only attribute is a sequence of 7-item sequences.

Each of these sequences contains information describing one result column:


The first two items (name and type_code) are mandatory, the other five are optional and are set to None if no meaningful values can be provided.

In adodbapi, the value of cursor.description[i][0] is obtained from the recordset as your patch suggests. However, some database engines (such as PostgreSQL) return their column header values as lower cased strings. There is no help for that. You should be able to get your list of the column names as provided by the engine using:

colNames = [d[0] for d in cursor.description]

Perhaps confusion is caused by adodbapi's cursor.columnNames attribute which is not part of the PEP. It is a dictionary of lower cased column names used to provide a namedtuple sort of index into the rowset. I should have named it cursor._columnNames to emphasize that it is an internal implementation detail, but I failed to do that.