1

Greetings Vim Experts!

I'm using gVim on windows 10, and installing the plugin vim-dadbod to work with Azure SQL (SQL Server). I believe the plugin is installed correctly as I see the connection string being turned into a SQLCMD in a pop-up window. The final command that vim-dadbod creates is using single quotes for all of the parameters & I think that is what is wrong. If I type out the same SQLCMD without the quotes (in a CMD window), it works. Has anyone had similar issues using vim-dadbod with SQL Server?

The manual connection string that works from a CMD window is:

sqlcmd -S SERVERNAME.database.windows.net -U USERNAME -d DBNAME -q "select name from sys.tables"

The command (copied from a screenshot) being generated from vim-dadbod is:

cmd.exe /c (^(sqlcmd -S 'SERVERNAME.database.windows.net' -U 'USERNAME' -P 'PASSWORD' -d 'DBNAME'^) ^< C:/Users/USERNAME/AppData/Local/Temp/VIiF7B1.tmp ^>C:/Users/USERNAME/AppData/Local/Temp/VIoF7B2.tmp 2^>^&1)

I assume the tmp files are for the actual query and returned results, but that's just a guess.

If I manually type out the SQLCMD with single quotes I get the same highly generic error as from vim-dadbod; which is: vim Error Curious since I'm not using ODBC, never mind Named Pipes...

Many thanks!

4
  • 1
    Welcome to Vi and Vim! :-)
    – filbranden
    Commented Nov 19, 2020 at 22:30
  • 1
    @filbranden you gave good advice :)
    – user32285
    Commented Nov 19, 2020 at 22:35
  • Do you have 'shellslash' enabled? Check it with :set ssl?. I ask because it seems this option affects the behavior of shellencode() on Windows...
    – filbranden
    Commented Nov 19, 2020 at 22:51
  • @filbranden Wow, yes I did! It's in the Vundle setup... :( I turned it off and now I get connections. In a stand-alone SQLCMD window; not really what I was expecting, and considerably underwhelming. Is vim-dadbod-ui the missing link to being able to run code that's in my vim window? P.S. Ordered a Macbook Pro with the new M1 chip today... maybe I can use that for work instead :D
    – user32285
    Commented Nov 20, 2020 at 1:35

1 Answer 1

1

In gVim (on Windows) the setup code for the package manager Vundle uses the command set shellslash in _vimrc.

This setting messes up the formatting of the command being sent to SQLCMD by vim-dadbod. By adding set noshellslash further down in the .vimrc (_vimrc on Windows) vim-dadbod then works.

Many thanks to @filbranden who suggested that was the issue!

4
  • Thanks for posting the answer that solved for you! I checked a bit on Vundle and 'shellslash' and I don't really see a requirement for it (on the contrary, I found some posts complaining that Vundle didn't work with it.) You usually need 'shellslash' when you're using a POSIX shell on a Windows platform. One example is "Git BASH", which is a build of the bash shell that comes bundled with a Git distribution for Windows. Otherwise, you don't need it. I'm glad disabling it after Vundle is working well for you!
    – filbranden
    Commented Nov 24, 2020 at 18:08
  • As a general suggestion (and I believe I already mentioned it in another question of yours), I usually recommend vim-plug as a more modern, well maintained alternative to Vundle. vim-plug has more features and better performance (by using more efficient git checkouts and performing operations in parallel.) Yet, it uses a similar execution model to Vundle and very similar commands, so it should be mostly familiar for users upgrading from Vundle. I really recommend it as a replacement!
    – filbranden
    Commented Nov 24, 2020 at 18:10
  • 1
    Thanks again @filbranden Yes, vim-plug is much easier to understand :) and I was able to get it running without Windows time-bombs like shellslash. vim-dadbod is working and it is everything I hoped for. All my SQL development can now be done interactively from Vim.
    – user32285
    Commented Dec 2, 2020 at 1:17
  • Excellent news @norton64, glad everything is working well for you. Thanks for the update!
    – filbranden
    Commented Dec 2, 2020 at 1:22

Your Answer

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