dbv is a fast and user-friendly terminal database viewer and editor that connects to SQL databases (with a focus on PostgreSQL). It provides a text-based interface for listing tables, browsing records, editing cells, generating SQL INSERT statements, creating Go struct definitions, exporting data to JSON, and more.
- List Tables & Views: Displays tables, views, and materialized views along with primary keys and approximate sizes.
- Data Browsing: Scroll through table records with built-in pagination.
- Cell Editing: Edit cell values directly with automatic conversions for timestamps and numeric types.
- Insert Statement Generation: Create template SQL INSERT statements that include default values and respect primary key order.
- Go Struct Generation: Generate Go struct definitions based on table columns (mapping PostgreSQL types to Go types).
- JSON Export: Convert table rows into JSON structures.
- Lua Configuration: Configure database connections using Lua scripts (e.g.,
init.lua
). - Keyboard Shortcuts: Navigate, filter, and execute commands with quick key bindings.
- Go 1.23 or later
- Clone the repository:
git clone https://github.com/crgimenes/dbv.git cd dbv
- Build the binary:
go build -o dbv
- Move the binary to a directory in your PATH (for example,
/usr/local/bin
):mv dbv /usr/local/bin/
- Run the application by simply typing:
dbv
You can also download the pre-built binaries from the GitHub Releases page. After downloading the appropriate binary for your operating system, place it in a directory that's in your PATH.
By default, dbv loads database connections from a Lua file named init.lua
. Place this file in either ~/.config/dbv/init.lua
or in the current directory. For example:
DataBases = {
{
title = "LocalDB",
url = "postgres://username:password@localhost:5432/mydb?sslmode=disable"
},
{
title = "OtherDB",
url = "postgres://user:pass@server:5432/otherdb?sslmode=disable"
}
}
After installing, simply run:
dbv
- Table Listing & Filtering: Easily navigate and filter available tables.
- Data Viewing & Editing: Scroll through records, edit cells, and generate SQL/struct/JSON using quick commands.
- Commands: Use
:where
,:insert
,:struct
, and:json
to interact with data.
h
,j
,k
,l
: Navigatione
,v
,p
: Edit/view the current cell:
: Open the command promptq
orEsc
: Exit
git clone https://github.com/crgimenes/dbv.git
cd dbv
go build -o dbv
mv dbv /usr/local/bin/
mkdir -p ~/.config/dbv
cat <<EOF > ~/.config/dbv/init.lua
DataBases = {
{
title = "LocalTest",
url = "postgres://postgres:mysecret@localhost:5432/mytestdb?sslmode=disable"
}
}
EOF
dbv
- Download the appropriate binary from the GitHub Releases page.
- Place the binary in a directory that is in your PATH.
- Run the application by typing:
dbv