Query Databases in Neovim (DBUI)
Compared to other SQL IDEs, I like using vim motions and Neovim for querying and copy the data in a new buffer. There’s two plugins that make this possibel:
- backend: tpope/vim-dadbod: Modern database interface for Vim
- UI: kristijanhusak/vim-dadbod-ui: Simple UI for above backend
# How that Looks
Some examples of how that looks like in practice.
# Tmux with Dadbod-UI (and dbt)
Dadbod-UI in action with Neovim and tmux:

See more at My Setup Images All in One (Tmux and Neovim)
# General Workflow Video
# Example with DuckDB from HTTPS CSV
Dadbod in Neovim to query any table or database within the terminal.

See the autocompletion that is activated and show penguins as suggestion as it’s an existing table. This also works for columns if setup correctly, see below Setup below.
Even DuckDB CLI in the Terminal has autocomplete 🤯
See below image with same example as above in nvim:
# Features
# Supported DBs
As of 2025-02-23, supports a modern array of backends, including NoSQL databases:
- Big Query
- ClickHouse: clickhouse://[<host>[:port]]/[<database>]
- Details see
- DuckDB: duckdb:/Users/sspaeti/Documents/duckdbs/playground-v1-1-1.duckdb
- Impala
- jq
- MongoDB
- MySQL
- MariaDB
- Oracle
- osquery
- PostgreSQL: postgresql:///foobar
- Presto
- Redis
- Snowflake
- SQL Server
- SQLite: sqlite:myfile.sqlite3 select count(*) from widgets
- Your own easily implemented adapter
- Easily configurable based on a project directory (as seen in rails.vim, for example), rather than just globally or in a per-file modeline
- For those that just can’t live without some piece of dbext functionality, the option
g:dadbod_manage_dbextis provided to force dbext to use Dadbod’s default database.
# Connect Databases
# DuckDB
|
|
My configs in database.lua:
|
|
# ClickHouse and Encode Password
If passwords contain speecial characters such as @ you need to encode it for it to work.
Connection string format:
clickhouse://user:password@host/database?secure
Example - for specific database
clickhouse://default:mypass@myhost.us-east-1.aws.clickhouse.cloud/staging?secure
Example - for all databases
clickhouse://default:mypass@myhost.us-east-1.aws.clickhouse.cloud?secure
?secureis required for ClickHouse Cloud (maps to--secureon the CLI)- Requires
clickhouse-client(orclickhouse client) installed locally - If passwords contain special characters like
@, you need to URL-encode them:
| Character | Encoded |
|---|---|
@ |
%40 |
# |
%23 |
? |
%3F |
/ |
%2F |
% |
%25 |
Quick way to get the encoded password:
|
|
# How to Setup
The best way to setup is checking my dotfiles at database.lua or TJ DeVries step by step video, including autocomplete with LSP at Vim Dadbod - My Favorite SQL Plugin:
My config from above:
|
|
Autocompletion
Note that autocompletion is a seperate plugin called kristijanhusak/vim-dadbod-completion
# Alternatives SQL Clients in the Terminal
- nvim-dbee: Interactive database client for neovim
- Use Neovim features only with exporting database into a variable and run the cli for the data base such as psql and return to vim. Great example by Henry Misc here: Run SQL in Vim Without Plugins.
- Or a curated list of any SQL IDEs, including terminal based.
# Futher Reads
Origin:
References: SQL IDEs
