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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.