Better ways to print out column names when using cx_Oracle

后端 未结 3 905
感动是毒
感动是毒 2021-02-01 08:39

Found an example using cx_Oracle, this example shows all the information of Cursor.description.

import cx_Oracle
from pprint import pprint

connec         


        
3条回答
  •  情深已故
    2021-02-01 08:57

    You can use list comprehension as an alternative to get the column names:

    col_names = [row[0] for row in cursor.description]

    Since cursor.description returns a list of 7-element tuples you can get the 0th element which is a column name.

提交回复
热议问题