Skip to content

Add table format option for drush sql:query output #5123

@gitressa

Description

@gitressa

Is your feature request related to a problem? Please describe.
drush sql:query works well, but for improved readability, is it possible to show the result in table format, showing the column names?

Currently

$ drush sql:query "SELECT table_name AS 'Table', TABLE_ROWS as 'Num. of Rows', round(((data_length + index_length) / 1024 / 1024), 2) 'Size in MB'  FROM information_schema.TABLES where table_schema = 'drupal9' and table_name LIKE 'cache_%'  ORDER BY (data_length + index_length) DESC limit 10;"
cache_1	73	2.55
cache_2	100	1.55
[...]

Would this be possible?

+---------+--------------+------------+
| Table   | Num. of Rows | Size in MB |
+---------+--------------+------------+
| cache_1 | 73           | 2.55       | 
| cache_2 | 100          | 1.55       |
+---------+--------------+------------+

Perhaps by adding a format option like this? drush sql:query --format=table "SELECT table_ ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions