kdwarn

Codeberg Mastodon Feeds

Introducing pgtui, a Postgres TUI client

March 16, 2026

terminal, database, rust | permalink

A couple years ago or so, I had an idea: "Write in markdown, save in database. This is how I'd like to interact with a database: use my favorite text editor and markdown to create a record (and mostly I'm thinking blog posts and the like), then that gets parsed out and stored in a database to get all the benefits of a database."

Since then, the idea has evolved slightly, but not terribly much. Rather than markdown, it's TOML, though it could be markdown (or HTML or plaintext or, I suppose, something else entirely) within the TOML. (And that is exactly how I'm writing at the moment.)

Mostly, it's been a lot of work to implement the idea, and pgtui, a Postgres TUI client, is the result. Since the initial 0.1 release in April 2025, which was just a placeholder, there have been many features added and even more bugfixes. One of the more difficult things was figuring out how to go back and forth between TOML and Postgres types, and sqlx was leaned on quite heavily for that. The toml library and ratatui were also crucial in development.

Here are the main features:

  • browse all non-system relations of a database
  • sort and filter those relations
  • view relation definitions/descriptions (this is the one part of the client where psql is used, though I plan on removing that reliance at some point)
  • browse paginated data in tables
  • sort data by column
  • filter data by writing a where clause
  • insert new records into a table (using your favorite terminal editor, of course)
  • edit records, with the ability to abandon midway (again, in a terminal editor)
  • view-only mode in editor
  • delete records (with confirmation required)
  • multi-column primary key support
  • store database connections in a configuration file, switch between them
  • in-client display of all available controls

Screenshots:

Here is a demo of version 0.10.0:

For further usage and installation instructions, see the README.