MySQL: Get column name or alias from query

后端 未结 10 1784
死守一世寂寞
死守一世寂寞 2020-11-28 20:04

I\'m not asking for the SHOW COLUMNS command.

I want to create an application that works similarly to heidisql, where you can specify an SQL query and w

10条回答
  •  佛祖请我去吃肉
    2020-11-28 20:41

    You can also do this to just get the field titles:

    table = cursor.description
    check = 0
    for fields in table:
        for name in fields:
            if check < 1:
                print(name),
            check +=1
        check =0
    

提交回复
热议问题