Neovim and SQL
With a few plugins, neovim can be a powerful SQL tool. Here are a few steps to get started.
dadbod.vim / dad
Install vim-dadbod-ui - check the installation instructions to see the dependencies.
One of them is dadbob.vim which is the foundation for everything. Int this repository you can see examples of connection strings for a few different database servers.
LazyVim
When using lazyvim, you can enable the "extra" related to sql:
https://www.lazyvim.org/extras/lang/sql. Do that by by adding to lua/config/lazy.lua:
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.sql" }, -- Add this line
{ import = "plugins" },
},
})
Using
With lazyvim, use <leader>D to start dadbod-ui. In there we can add a
connection. For me, with mysql, it was on this format: mysql://user@pass:localhost:3305, alternatively, scope the connection to a single database/schema by adding /database-name at the end.
Navigate to a table and choose list to get a query that will select the first
couple of hundred items automatically.