
Vim-db: Modern database interface for Vim - petercooper
https://github.com/tpope/vim-db
======
djtriptych
Should mention in the comments that this is written by Tim Pope, probably the
foremost vim plugin author of the last decade. He also wrote pathogen, vim-
surround, vim-repeat, etc etc etc.

[https://github.com/tpope?tab=repositories](https://github.com/tpope?tab=repositories)

~~~
badosu
Shout out to Tim Pope!

I follow his work since I started using Vim ~ 8 years ago, the absolute
pinnacle for me being vim-fugitive, I can't live without it!

------
falcolas
I don't want to be Debbie Downer, but what's the usecase for this tool that
isn't better suited for a client in a separate terminal? I am guessing that
the two biggest answers would be the :%DB command and the variable setting,
but given the ease of switching and copy-pasting between terminals, this seems
superfluous. Maybe it's for easier integration into other plugins?

Personally, if I was looking for a DB integration with VIM, I'd be looking for
an interactive prompt style buffer instead of per-command executions.

~~~
freshhawk
> I'd be looking for an interactive prompt style buffer instead of per-command
> executions

> given the ease of switching and copy-pasting between terminals, this seems
> superfluous.

This really makes me think you are a prime candidate for a plugin that can
easily open an interactive prompt or make the whole copy, switch terminal,
paste, copy response flow one command.

This is just repl-integration for db repls (interactive prompts if you
prefer).

Many people are used to this workflow:

Open your editor, open a prompt in another terminal. Write the simple stuff in
the prompt, the complex stuff in your editor and then copy/paste to the
prompt. Write a simple query in the prompt that ends up pretty complex, so you
copy it, switch to the editor and paste, fix it up then copy, switch to prompt
and paste it back. Now you copy part of the query results, switch to editor
and paste so you can extract some of the results for the next complicated
query.

A lot of us know this workflow, an many of us aren't aware that what we are
looking for is repl integration in the editor. Same workflow, goes like this:
edit query, eval, edit again, eval, etc. It is not a different way of working,
it is the same way but much better.

How do you know if you want this? If you use vim and set your readline config
to use vi keybindings you want this. You already noticed that editing stuff in
the prompt is worse than in vim, you just picked the wrong fix for that
problem.

~~~
falcolas
If you use tmux, the transmission of a command from Vim to another tmux pane
is remarkably simple. It's just a shell out to the tmux binary with the
appropriate arguments.

My problem with vim-integrated shells, prompts - anything inherently
interactive except for editing itself - is that it's always worse. Be it
performance, integration between vim and the interactive prompt, or an
impedance mismatch between vim's modal editing and an interactive prompt's
non-modal editing. I'd rather switch windows and use a native shell than a
kinda-working shell in vim. Same with a DB prompt. Same with pretty much every
other tool I pull up in the terminal.

Honestly, it's the same reason I don't use emacs with EVIL mode: it's not
quite vim, and those speedbumps absolutely kill my "Flow". Any gains from a
rich editing environment are lost (with interest) by trying to figure out how
to get the non-editing part of that environment to behave correctly. And I
even use emacs bindings in bash (no, not zsh or fish or...); because then when
I go to remote servers, everything _just works_.

That's my opinion, at least.

~~~
freshhawk
But this plugin is, framed in terms you might be more familiar with, a plugin
that wraps the "shell out to the tmux pane then copy the output into the
buffer I'm in" step. That's it.

This isn't a vim-integrated shell solution, it's a way to avoid those, for
exactly the reasons you say. Repl integration isn't about embedding a prompt
in your editor, it's about bypassing the interactive prompt because you
already have a place to write and read text - an editor buffer. I should have
used a different term obviously, that one is actually misleading.

Part of the reason I'm curious is I regularly do Clojure training and see this
pattern over and over: "I don't like working that way, that sounds bad. [hours
later it clicks] Oh! I see what you mean, this is great. This is the way I
like working but easier! I thought you meant something different".

~~~
falcolas
True, sorry, was just really wanting to point out how easy such a thing is,
then got distracted on a tangent on why I don't want windows embedded in my
vim.

------
blaisio
Everyone should probably be paying Tim Pope some sort of tribute for all the
software that has been written more quickly because of his plugins. Companies
working on other editors should be trying to recruit him!

------
hucker
Shameless self-promotion incoming, but if you're mostly using postgres (like
me), you can take a look at
[https://github.com/martingms/vipsql](https://github.com/martingms/vipsql) as
well.

~~~
aidos
Nice work! I use (a slightly modified version of)
[https://github.com/ivalkeen/vim-simpledb](https://github.com/ivalkeen/vim-
simpledb)

Looks pretty similar to yours. I definitely like that model of editing /
execution.

------
dguaraglia
I see Tim Pope, I upvote. This guy has produced some of the plugins that have
changed how I Vim forever (vim-surround, pathogen, vim-repeat, vim-fugitive,
etc.)

------
agumonkey
I'd love to see a screencast. I'm mostly an emacser but I like vi ergonomics
very much, and would love to see the approach here.

~~~
marrone12
Why not just use evil-mode in emacs?

~~~
agumonkey
I'm not in the mood for learning UI right now. Also it's beside my question.
I'm curious about vi culture and vi fanatics (or fetishists, or satanists,
forgot the proper terminology).

------
pweissbrod
This is a very nascent project but started by one of the best vim developers
around, Tim Pope. As someone who has run into some of the rougher edges from
time to time of dbext I applaud this effort and will closely watch progression

------
krzyk
It's a pity it doesn't support Oracle. Some corps force developers to use it.

~~~
gaius
So make the case for Postgres and show the business how much cash they will
save. Don’t submit to your fate, fight it.

~~~
always_good
In my experience, the organization is well aware how much they need to switch
away from Oracle. They're reminded every billing period. By then it's just no
small feat.

Look at Amazon, aggressively trying to move away from Oracle yet still far
away.

~~~
mordae
We want to get rid of it for years now, but say that to the accounting dept.
with their ancient Oracle Forms ERP.

~~~
gaius
Ironic that the beancounters waste the most money. Remember that when they
want to make cuts.

------
purplezooey
SQlite support. awesome.

~~~
joehan
Not integrated in vim, but try visidata
([https://github.com/saulpw/visidata](https://github.com/saulpw/visidata)) on
Sqlite. I tried after HN post last weekend and it was amazing... with Vim-like
keys and interface.

------
claudio_alvarez
Is it hard at all to exit vim-db?

