Skip to content Skip to navigation

drush sqlq formatting

Author: 
Topics: 

How To

Ever get frustrated about the output from 'drush sqlq'?

Add '--extra="-t"' to your 'drush sqlq' command, and get a nicely-formatted table. ("--extra" allows you to include any options you would pass to 'mysql').

(Run 'man mysql' to see more options to pass to '--extra'.)

Before

corn18:/afs/ir/group/mygroup/cgi-bin/drupal> drush sqlq 'select * from {path_redirect}' 
rid     source  redirect        query   fragment        language        type    last_used
1       content/test-page       node/1                          301     1342492913
3       content/test-page-2     test-page                               301     1342493077
5       blah    test-page                               301     1342493434
7       foo     test-page       NULL    NULL            301     1342493769

After

corn18:/afs/ir/group/mygroup/cgi-bin/drupal> drush sqlq --extra="-t" 'select * from {path_redirect}'
 
+-----+---------------------+-----------+-------+----------+----------+------+------------+
| rid | source              | redirect  | query | fragment | language | type | last_used  |
+-----+---------------------+-----------+-------+----------+----------+------+------------+
|   1 | content/test-page   | node/1    |       |          |          |  301 | 1342492913 |
|   3 | content/test-page-2 | test-page |       |          |          |  301 | 1342493077 |
|   5 | blah                | test-page |       |          |          |  301 | 1342493434 |
|   7 | foo                 | test-page | NULL  | NULL     |          |  301 | 1342493769 |
+-----+---------------------+-----------+-------+----------+----------+------+------------+