Vim Tips Wiki

Capture SQL query output

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 104 Printable Monobook Previous Next

created September 3, 2001 · complexity advanced · author meonkeys · version 5.7

DBI::Shell is a Perl module that is used as a shell interface to Perl's popular DBI (database interface) package. Forget your favorite SQL navigation gui and give this method a shot. This has only been tested in Unix.

1. Run dbish (runs DBI::Shell; installed with DBI::Shell) and connect to any database.

2. In dbish, set /format box.

3. Enter your query.

4. To execute query, type "/ | vim -"

This runs the query and pipes the output to the standard input of Vim.

Here are some follow-up tips:

  • Use gvim instead of Vim so a new window will pop up.
  • Set nowrap once in Vim.


Note that if your are using MySQL cli, you can type : "pager vim -" (without the quotes indeed).

Then every select, desc, show, etc. will be opened in Vim.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki