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 you can add 'WHERE ...' to restrict it to just certain fields. But I can't find an example of how to return just the names of the columns, and not Type, Key, Null, Extra information.
What is the matching criteria to pull all field names for columns and none of the other description stuff?
The information_schema. COLUMNS table holds all information about the columns in your MySQL tables. To exclude columns, you use the REPLACE() and GROUP_CONCAT() functions to generate the column names you wish to include in your SELECT statement later.
Syntax. The following is a syntax to display the column information in a specified table: SHOW [EXTENDED] [FULL] {COLUMNS | FIELDS} {FROM | IN} table_name.
The syntax of the INSERT IGNORE statement is as follows: INSERT IGNORE INTO table(column_list) VALUES( value_list), ( value_list), ... Note that the IGNORE clause is an extension of MySQL to the SQL standard.
SELECT column_name FROM information_schema.columns WHERE table_name = 'your_table' AND table_schema = 'database_name'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With