dict_cur = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
dict_cur.execute("SELECT column1, column2, column3 FROM mytable")
result = dict_cur.fetchall()
print result[0]
>>> {'column2':10, 'column1':12, 'column3':42}

How could I preserve column ordering without parsing executed SQL first? It works well with normal cursor when list is returned, but I need access to dictionary keys and therefore need to use RealDictCursor.

EDIT: Well, I actually can't. description attribute of the cursor object should be used for getting column names.

Edit
Report