11

This might be more suitable for IDE, not for Vim, but still I would appreciate if there was a way that would allow me to connect to either local or remote MySQL/SQLite databases. Is there such a way to do this?

I think it could be placed in a split window or in its own tab. I would want to read, update, delete rows, import/export sql. Some advanced features like foreign keys could be, obviously, omitted.

2
  • 2
    I know this plugin from a colleague who worked with it. I know this plugin works but I don't personnaly have enough experience to give you some precises informations about it.
    – statox
    Commented Jun 24, 2015 at 15:56
  • 1
    Basic vim will not work for what you want because it is built to edit text. What people normally do is to have a terminal/console open in parallel to execute those commands. But you might try neovim if you really need to have a terminal running inside vim...
    – Vitor
    Commented Jun 25, 2015 at 11:05

3 Answers 3

3

Even though I agree with @Vitor's comment saying that Vim is not meant to interact with a database, here is another solution:

Tim Pope recently released vim-dadbod that he calls "a more modern take on dbext.vim"

DB is a Vim plugin for interacting with databases.
It's a more modern take on dbext.vim, improving on it on the following ways:

    - Connections are specified with a single URL, rather than prompting you
      for 14 separate variables
    - All interaction is through invoking :DB, not 53 different commands and 35
      different maps (omitting many of the more esoteric features, of course)
    - Supports a modern array of backends, including NoSQL databases:
        - MongoDB
        - MySQL
        - PostgreSQL
        - Redis
        - Sqlite
        - Your own easily implemented adapter
    - Easily configurable based on a project directory (as seen in rails.vim, for example),
      rather than just globally or in a per-file modeline

From what I tested the postgresql integration works fine, given the usual quality of Pope's plugins there's a chance that it is a good solution.

1

I'm myself trying to work it out these days. I think dbext might help.

You can find many third-parties from vim-scripts on GitHub.

1

As others have mentioned, dbext is probably what you are looking for. I've been using it for a while now to run queries against a (an?) SQL Server database. I've only used it for simple querying of stuff, but I believe it can insert, update, delete, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.