I have a raw sql join statement that I'm executing through session.execute, however the result isn't providing me with column names, just the column values. How would I get my column names so that I can assemble it into a dictionary value for JSON dumping?
def get(self, pow_id):
try:
results = db.session.execute(''
'SELECT * FROM POW p JOIN completed_course cc1 on p.student_id = cc1.student_id '
'JOIN term_course tc on cc1.term_course_id = tc.id '
'JOIN completed_course cc on tc.id = cc.term_course_id '
'LEFT JOIN specialization_course sc on tc.course_id = sc.course_id '
'AND sc.specialization_id = p.specialization_id '
'WHERE p.id = :val;', {'val': pow_id})
for row in results:
print(row)
return {}, 200
except Exception as e:
raise Exception("")