最佳答案
from pandas import DataFrame
import pyodbc
cnxn = pyodbc.connect(databasez)
cursor.execute("""SELECT ID, NAME AS Nickname, ADDRESS AS Residence FROM tablez""")
DF = DataFrame(cursor.fetchall())
This is fine to populate my pandas DataFrame. But how do I get
DF.columns = ['ID', 'Nickname', 'Residence']
straight from cursor? Is that information stored in cursor at all?