Vim/Neovim — Managing Databases
Managing databases and running SQL statements, all within Vim/Neovim.
Overview
In my previous article, I walked through with you how to manage multiple projects within Vim/Neovim. In this article let’s extend this to see how to manage multiple databases.
Setup
I am going to use PostgreSQL and MySQL as examples. For this to work, on the client machine you will need to install the database clients.
- For PostgreSQL, you will need libpq. Depending on your operating system, you can follow the instructions here to install PostgreSQL client.
- For MySQL, you need MySQL client. You can install the component using the MySQL installer. Alternatively, depending on your operating system, you can use
brew install mysql-client
(MacOS)orapt-get install mysql-client
(Linux).
Other databases are also supported. More on this later.
If you want to use Docker for MySQL and PostgreSQL for testing, you can refer to this docker-compose.yml file.
You can find the initialization SQL and .env files from this repository.
Plugins
I am going to leverage the Lua-based dotfiles I developed in my previous article. However, the plugins should work for both Vim and Neovim.
Under lua/plugins.lua
, install these 2 plugins.
-- Database
use { 'tpope/vim-dadbod' }…