MySQL describe table output as query

Hi there.
I am working on a small Python script to automate MySQL DB migration on a PacsOne DICOM server.
I want to get the structure form one DB and append it to another DB.
I’m a little stuck on a problem with MySQL. When I run a ‘describe table’ query in Python, the output I get is like ‘path varchar(255) NO None’. The NO stands for NOT NULL.

| Field | Type | Null | Extra |
±--------------------±---------------------±-----±----±--------±------+
| studyuid | varchar(64) | NO | NULL |

Is there any way in MySQL to see the ‘describe table’ output as a query, e.g. “path varchar(255) not null;” ?
Thanks a lot in advance!

I’ve never used it but this might be worth a look?

The command:

show create table DB_NAME.TABLE_NAME;

generates the sql command needed to create the table.

2 Likes

TNX a lot!!!

If you’re looking to parse this, SHOW INDEX FROM db.table could also be useful to you. The information is included in the SHOW CREATE TABLE output also, but this might make things easier to handle.