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
Although it looks more elegant, you don't need awk for this. MySQL's information_schema.columns table has the info you need.
-- DESCRIBE THE HECK OUT OF THE ENTIRE 'table_name' table in the 'database_name' database
SHOW COLUMNS
FROM database_name.table_name ;
-- SHOW JUST THE COLUMN NAMES for 'table_name' table in the 'database_name' database.
SELECT column_name
FROM information_schema.columns
WHERE table_schema = 'database_name'
AND table_name = 'table_name' ;