MySql: Show columns but exclude everything except the field names

前端 未结 6 652
陌清茗
陌清茗 2021-01-30 13:36

I\'d like to pull a table\'s field names from MySql into python, and I know that

\'show columns from project\'

will work. And I\'ve read that

6条回答
  •  生来不讨喜
    2021-01-30 13:45

    You can query MySQL's information_schema database directly for the fieldnames:

    select distinct(COLUMN_NAME) from information_schema.COLUMNS where TABLE_NAME='posts';
    

提交回复
热议问题