cursor.execute( "SELECT TABLE_NAME, TABLE_COMMENT FROM information_schema.TABLES WHERE table_type='BASE TABLE' AND TABLE_SCHEMA='%s'" % database_name )
cursor.execute( "SELECT ORDINAL_POSITION, COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_COMMENT " "FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='%s' AND TABLE_NAME='%s'" % ( database_name, table[0] ) )
tmp_table = cursor.fetchall() p = markdown_table_header % (table[0], remove_newline(table[1])) for col in tmp_table: p += (remove_newline(markdown_table_row % col) + "\n") print(p) f.writelines(p)