What do I want from a SQL plugin? Mostly quickly checking tables and their structure, running queries, and saving those for later. Two plugins cover all of it:

The Venerable Vim-dadbod

I've been aware of this 8-year-old plugin (note: dadbod = db = database?) since it was created but didn't have much reason to use it. For my occasional DB usage, the mysql CLI has been fine but not great. I decided to start here on a new sqlite-based project.

It gives you a command that allows you to run an arbitrary SQL by providing the connection string and query in the command:

-- the connection string here refers to a local file holding a sqlite database
:DB sqlite:myfile.db select count(*) from widgets

You can have queries in a file and run them by selecting them in visual mode and typing the command :DB sqlite:myfile.db<CR>. (One can imagine having project-specific mappings, see :help exrc, such that typing <leader>S runs the query against the project's main DB.)

select count(*) from widgets;
select count(*) from sales;

-- more complex query
select ...
from ...
  join ...
  where ...

This works, but it's not a particularly good UX. I also know from experience managing these types of things in files can grow out of hand: where do you save the files in the project? If the number of queries grows, do you need more than one file? A whole folder system?

Vim-dadbod-ui: A Simple UI

Using vim-dadbod as a dependency, vim-dadbod-ui provides a fully featured DB-management interface by typing :DBUI, seen here navigating to a table and showing its columns:

vim-dadbod-ui navigation tree open to a table, its columns shown on the bottom

One of the answers to the question "why do this in vim" is present in the UI: the keys I use to navigate, open and close folds, and run the query are the same ones I've had in muscle memory for nearly 20 years of vi/vim/Neovim usage. I wouldn't want to edit this saved query on the right here in the basic equivalent of an HTML text field:

vim-dadbod-ui complex saved query open, with results shown on bottom

It runs the queries on save, which is useful for SELECTs, but since I have vim auto-save on, that's quite dangerous for UPDATEs or DELETEs. I'm just using the default config for now so perhaps that can be changed. In the meantime I'm finding this plugin quite handy!