One command, full Postgres GUI: meet pgdeck

2026-11-28来源 dev.toEnglish
One command, full Postgres GUI: meet pgdeck

I spend a lot of time inside PostgreSQL. Most days I want to do something small: look at a few rows, fix one value, check why a query is slow, or load a CSV someone sent me.

For that, the usual options always felt like too much. A desktop app to install and update, a Docker container to run, or a config file to write. Or I'd just use psql, which is great until you want to scroll through 18,000 rows or edit a timestamp without typos.

So I built pgdeck: a full web UI for Postgres that starts with one command.

npx pgdeck postgres://user:password@localhost:5432/mydb 

That's the whole setup. It connects, starts a local web app, and prints a URL and a login:

 pgdeck v0.1.6 ✓ Connected mydb as postgres (PostgreSQL 18.1) Databases 12 available (switch in the UI) ➜ Web UI http://127.0.0.1:47615/ Listening 127.0.0.1:47615 Login admin / 3fH9kQ2xLmP_ 

Open the link and you're in. No Docker, no config file, no desktop app.

pgdeck live overview with connections, transactions per second, cache hit ratio and sessions

What it does

A live overview of your database

The first screen shows what's happening right now, streamed over a WebSocket: connections, transactions per second, rows read and written, cache hit ratio and running sessions.

Below that are health checks I always end up writing by hand: tables with lots of dead rows, missing indexes, tables that were never analyzed and sessions stuck "idle in transaction". The affected tables can be vacuumed or analyzed in one click.

You can also switch between every database on the server from the header (or with ⌘K) without restarting anything.

A data grid that respects your types

pgdeck data grid showing an orders table

Sort, paginate and filter with =, ≠, <, >, contains, starts with, in, like, is null and more, combined with AND or OR.

Foreign key columns show what they reference. You can preview the referenced row from any cell and jump straight to it.

Editing picks the right input for each column type:

  • enum columns get a dropdown
  • booleans get a toggle
  • dates and timestamps get a calendar, and the timezone offset is preserved
  • JSON gets an editor with validation
  • UUIDs can be generated
  • any field can be set to NULL or DEFAULT

Editing a row in pgdeck with type-aware inputs

One decision I'm happy with: pgdeck reads every value as Postgres' own text representation and sends edits back the same way, so Postgres does the casting. That means bigint and numeric never lose digits to JavaScript numbers, and timestamps keep their precision and timezone. If you can type it in psql, it works in the editor.

A SQL editor with query plans

pgdeck SQL editor

The editor has syntax highlighting, table autocomplete, multiple statements, error position highlighting and per-database history. ⌘ Enter runs the selection or the whole editor.

⌘ ⇧ Enter explains the statement as a plan tree: time per step, estimated vs. actual rows, the slowest step highlighted, and plain-language warnings like "this filter discards most rows" or "this sort spilled to disk". Explain analyze runs the query for real timings inside a transaction that is always rolled back, so it's safe on UPDATE and DELETE too.

The overview also lists the slowest queries from pg_stat_statements (with setup help if it's off), and you can cancel a query or terminate a session from there.

Schema management without writing DDL

pgdeck table structure view

  • Create tables with a column builder and a live SQL preview
  • Add, rename, retype and drop columns
  • Create indexes (multi-column, unique, partial, btree/gin/gist/brin/hash, CONCURRENTLY)
  • An interactive ER diagram you can export as PNG or SVG
  • Roles and permissions: a privilege grid where you tick boxes, review the SQL, and save it in one transaction
  • Functions, triggers, sequences and extensions, all editable in place

Creating a table in pgdeck with a live SQL preview

Import and export gigabytes

Streaming a CSV import into Postgres with pgdeck

Imports stream CSV, TSV or JSON Lines files (gzipped too) straight into Postgres using COPY. Nothing is buffered in memory, so file size doesn't matter. It all runs in one transaction: if row 2,000,001 is bad, everything rolls back and you're told the exact line.

Exports work the same way in reverse. Export everything that matches your filters (streamed from a server-side cursor), the current page or selected rows, as CSV, TSV, JSON, JSON Lines, SQL INSERTs or Markdown.

You can also back up and restore whole databases: a pg_dump-style .sql (optionally gzipped) taken from one consistent snapshot, or a ZIP with the schema plus one data file per table. Restore accepts pg_dump backups too.

Secure by default

A web UI for your database needs to be careful, so pgdeck starts locked down:

  • Login required, with a random password printed at each start (or set your own with --password / PGDECK_PASSWORD)
  • Binds to 127.0.0.1 unless you pass --host
  • CSRF protection on every API call, and WebSocket origin checks
  • Rate-limited login attempts
  • A --readonly mode that opens every session read-only and turns off editing in the UI
# Read-only look at production, with a fixed password PGDECK_PASSWORD='correct horse battery staple' npx pgdeck "$DATABASE_URL" --readonly 

It also works behind nginx, Caddy or Traefik. It's one port with relative URLs, and there's an optional --base-path if you want to serve it under /db.

How it's built

  • Server: Hono on Node.js, with node-postgres
  • UI: React, TanStack Query, shadcn/ui, Tailwind CSS and CodeMirror
  • Build: Vite for the UI and tsdown for the CLI, bundled into a single self-contained npm package

Building pgdeck taught me a few things:

  1. Never trust JavaScript numbers with database values. Keeping everything as Postgres text was the simplest way to never lose precision.
  2. Stream everything. COPY FROM STDIN and server-side cursors mean a 5 GB import uses about as much memory as a 5 KB one.
  3. Zero-install is a feature. If trying a tool takes one command, people actually try it.

Try it

You need Node.js 20+ and PostgreSQL 12+.

npx pgdeck postgres://postgres@localhost:5432 --open 

pgdeck is open source (MIT) and still young, so feedback really helps. If something breaks or a feature is missing, please open an issue. And if it saves you some time, a star on GitHub means a lot. 🙏

What do you use to manage Postgres day to day? I'd love to hear about it in the comments.

原文:https://www.a8q9.cn/en/article/one-command-full-postgres-gui-meet-pgdeck-87f77e.html

相关文章