192 points · by achristmascarl · 2y ago · 49 comments
Asking because running queries, history, formatting of results etc. can be achieved by configuring psqlrc.
- results are formatted nicely by default; no more doing a first query, getting too many columns so results wrap unreadably, then changing the columns for a second query, and so on
- manually editing rows is as easy as with a spreadsheet; of course hopefully you don't have to do this often...
- I can change common filters & sorts in the UI with a few clicks instead of having to change SQL; sure, the SQL would only require typing a few characters, but if it's 2 clicks vs. 8 characters, it's still a small win
Downsides are:
- the GUI has an interface for saving queries, but it refuses to let me save them to a subfolder of my project; it wants to save them all in some global location. This doesn't seem good for sharing queries
- if you are doing more complicated sorting or aggregation, it's still easier to just go to psql than to fiddle with the GUI
another one is a more comfortable editing experience for queries
rainfrog --url $(heroku config:get DATABASE_URL -a simonwillisonblog)I pretty much always use DataGrip or pgcli and don't see that changing, but will keep an eye on this.
Not sure if that would be a viable option in Rust.
Ref: https://www.gnu.org/software/bash/manual/html_node/Bash-Vari...
https://github.com/achristmascarl/rainfrog/blob/main/src/app...
This seems mostly ok. The only thing that (imo) wouldn't pass code review is that big honking loop at https://github.com/achristmascarl/rainfrog/blob/main/src/app.... That thing needs to be refactored down to be readable, with individual logic chunks being put into their own functions and tidied up a bit.
That's not really Rust-specific, obviously, but all the `match` and `if let` and whatever other Rust stuff looks fine, so it's what I've got.
What do you use for the DataTable widget? Is there a Rust/Ratatui equivalent of DataTable (https://textual.textualize.io/widgets/data_table/) used by Harlequin?
--
\c
\d
\di
\dt
And the variants (e.g. \dti+)I've been wanting to get into building a TUI but can't decide which library to pick.
Charm/bubbletea toolstack, is very much focused on an ELM style architecture, I.e. message passing and deriving UI from state. You can still do immediate type UI if that is what you prefer, but it won't fit with any of the standard components. Bubbletea is a framework more or less, so even if you know Go, it will require you to learn how to build to its strengths.
Ratatui is by default not very opinionated about how to handle state and updates, which requires some development from you, or using a third party library to get an opinionated architecture around it. Ratatui is more of a collection of libraries, out of the box, it expects a certain interface for components, but it is up to you how you want to compose them together. Whether that is immediate-, stateful-, react-, or ELM style. Stateful is the default for all their examples.
Charms way of doing terminal UI is very much based around strings, which can sometimes give issues with spacing, as components can be fiddly to be constrained within a certain space.
Ratatui creates UI on top of a matrix of bytes, which makes it more difficult to do easy things, but allows you to more easily build complex uis.
Generally I prefer Ratatui, as you can really build robust and fast uis on top of it. It does take a bit more work to get started though. I am also biased by Rust tho.
The lack of opinionated approach stems from Ratatui being not a framework, but a library (you call us, we don't call you), and not having any of the event/input handling things included.
There's likely room for a framework or two on top of it.