To get column names in one separate comma.
colNames = "" for i in range(len(cursor.description)): desc = cursor.description[i] if i == 0: colNames = str(desc[0]) else: colNames += ',' + str(desc[0]) print colNames
Alternatively, pass the column names to the list and use .join to get them as a string.
colNameList = [] for i in range(len(cursor.description)): desc = cursor.description[i] colNameList.append(desc[0]) colNames = ','.join(colNameList) print colNames
Robert
source share