0

I 've a following query that going to use in python api.

SELECT n.FIRST_NAME as "NAME", a.STREET_1 as "ST1", a.STREET_2 as "ST2" FROM SCHE.EMPLOEE_NAME n, SCHE.EMPLOYEE_ADDR a 
WHERE n.eid=a.eid
AND n.estatus='ACTIVE'

The above query yields the result

cursor().execute(sqlQuery)
sqlTupleRows=cursor().fetchall();
sqlQueryReturnedDict={};
for sqlTupleRow in sqlTupleRows:
  columns=cursor().description
  ......

Here the column names returns as ('NAME','ST1','ST2') instead of ('FIRST_NAME', 'STREET_1', 'STREET_2'), but I need to fetch column names as it is from database table what we used in query rather than alias, how do we fetch taht information?

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by ryantroop
0

If you want the field name directly, simply don't use an alias. By defining FIRST_NAME as NAME you are asking to return "NAME" with the contents (the alias is there to lessen the amount we have to type). If you don't want them, dont use them.

If that wasnt clear, try running it as "SELECT n.FIRST_NAME, a.STREET_1, .... " and see what you get.

Ryan

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.