Using neovim + <a href="https://github.com/kassio/neoterm" rel="nofollow">https://github.com/kassio/neoterm</a> 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:<p>- I open a :Term window, in which I run the sql client (i.e. ":Texec sqlite\ foo.sqlite" or ":Texec mysql\ foo", etc)<p>- From there, I can run whatever SQL command normally.<p>If I'm then in another buffer, and assuming there's only one :Term open, I can:<p>- 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<p>- alternatively, :TREPLSendLine to send the current line<p>- alternatively, :TREPLSendFile to send the whole file (useful when the whole file both undoes and does things, to easily recreate a database structure)<p>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.
These kinds of plugins are not worth installing & configuring & learning in my humble opinion. Just type \e in the psql shell and voila, edit your sql in vim.<p>Just a little bit of UNIX knowledge saves you a load of unnecessary plugin installs.<p>To be clear; this is not some kind of premature optimization argument. I think plugin installs are ok as well as their memory & persistent storage requirements. What I worry about is the storage capacity of my brain.<p>I don't want to know about one more plugin unless it introduces a significant benefit on top of the already existing capabilities of the program in question.
Religious affiliations aside, I'd be somewhat surprised if Vim doesn't have some generic mechanism to talk to external interactive processes like Emacs' comint. I use sql-mode on top of that for most of my database interactions and it's great being able to use all my normal editor commands and muscle memory there (same as my terminal and various REPLs).
I used dadbod[0] and the following in my vimrc[1] to do a similar thing, only I haven't make the shortcuts for sending a block yet.<p>Looks nice though, maybe I'll try it out sometime!<p>[0] <a href="https://github.com/tpope/vim-dadbod" rel="nofollow">https://github.com/tpope/vim-dadbod</a><p>[1] au FileType sql nmap <leader>d :%:DB g:db<CR>
Multiline is what makes REPLs or CLI break, interesting and simple take on it. Fish tries to solve this by having a good CLI editor for multilines. This is preferable to a notebook for me especially if done with the "paste to tmux pane" described in comments. I will use this in FWed production systems next week!
See also Dadbod UI on (neo)vim to interact with databases: <a href="https://github.com/kristijanhusak/vim-dadbod-ui" rel="nofollow">https://github.com/kristijanhusak/vim-dadbod-ui</a>