Skip to content

Comment on PostgreSQL Sessions in Vim

Comments

Using neovim + https://github.com/kassio/neoterm I have a similar, possibly simpler, workflow that doesn't require any other program (especially listening willy nilly with no authentication/authorization whatsoever) other than your normal SQL client running:

- I open a :Term window, in which I run the sql client (i.e. ":Texec sqlite\ foo.sqlite" or ":Texec mysql\ foo", etc)

- From there, I can run whatever SQL command normally.

If I'm then in another buffer, and assuming there's only one :Term open, I can:

- visually select something, and :TREPLSendSelection to have it sent to the terminal along with a newline, thus executed (i.e. type ".schema" on one line, V then :TREPLSendSelection, ENTER, done - it gets executed in the terminal and the output shown) or "vap" to select a full paragraph and :TREPLSendSelection to send it all, for multi-line queries

- alternatively, :TREPLSendLine to send the current line

- alternatively, :TREPLSendFile to send the whole file (useful when the whole file both undoes and does things, to easily recreate a database structure)

I've found those simple things ("just have a terminal", "send stuff to it") to be very powerful, without having additional tools which, moreover, listen willy nilly on the network.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.