vim-dadbod icon indicating copy to clipboard operation
vim-dadbod copied to clipboard

ms sql adaptor string

Open gilfra0000 opened this issue 6 years ago • 22 comments

I am a beginner attempting to start an interactive console with mssql using the adapter string specified in the help documentation:

    sqlserver://[<user>[:<password>]@][<host>][:<port>]/[<database>]
    sqlserver://[<host>[:<port>]][;user=<user>][;...]

I'm using gvim 8.1 and MS SQL Server Management Studio v18.2 installed on a win 10 desktop, so I believe I don't have host or port details (perhaps thats the issue?)

I do have a server name, username and password, and a database name ('test') which I've used as follows:

    DB sqlserver://<username>:<password>@<DESKTOP-*****/SQLEXPRESS>/test

but sadly there is no visual indication that a console has started. I've tried to create a table but again no joy.

Help very appreciated.

gilfra0000 avatar Aug 31 '19 20:08 gilfra0000

Do you have dispatch.vim installed?

tpope avatar Sep 03 '19 23:09 tpope

Hello, I did not, but I have just installed it.

gilfra0000 avatar Sep 04 '19 22:09 gilfra0000

To clarify I have installed it and hoping for further guidance. Thank you for taking the time.

gilfra0000 avatar Sep 05 '19 12:09 gilfra0000

What is happening?

tpope avatar Sep 05 '19 20:09 tpope

  1. I run the vim command:

    Start DB sqlserver://username:password@host/database

  2. The command as it appears on the command line gets changed to:

    :DB! sqlserver://username:password@host/database (windows/?)

  3. A console window pops opens. The title bar of the window is C:\WINDOWS\SYSTEM32\cmd.exe, and the message it contains reads:

'DB' is not recognized as an internal or external command, operable program or batch file. Press any key to continue...

  1. I press any key. The window closes. The command remains on the vim command line.

An internet search indicates that a missing entry in the 'Windows Environment Variables' list may be the cause, so I've included a list system path variable values.

%SystemRoot%; %SystemRoot%\system32; %SYSTEMROOT%\System32\OpenSSH; %SystemRoot%\System32\Wbem; %SYSTEMROOT%\System32\WindowsPowerShell\v1.0; C:\Program Files\Microsoft SQL Server\140\Tools\Binn; C:\Program Files\Microsoft SQL Server\140\DTS\Binn; C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn; C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn; C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn; C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio; C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn; C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn; C:\Program Files (x86)\Yarn\bin; C:\Program Files\PuTTY; C:\Program Files\nodejs;

gilfra0000 avatar Sep 06 '19 12:09 gilfra0000

Don't run :Start DB, run :DB and it will invoke :Start for you.

tpope avatar Sep 06 '19 17:09 tpope

Nothing happens. There isn't an error message or any apparent indicator of activity. Dispatch and dadbod are in /pack/plugins/start. Other plugins there are working. I can write directly to the database using Server Studio.

gilfra0000 avatar Sep 07 '19 16:09 gilfra0000

What if you call :Start cmd.exe?

tpope avatar Sep 08 '19 01:09 tpope

  1. The command on the command line changes to !cmd.exe (windows/?.

  2. A console window pops opens ( C:\WINDOWS\SYSTEM32\cmd.exe) It shows a command prompt.

gilfra0000 avatar Sep 12 '19 06:09 gilfra0000

I'm unclear what's going on. Try changing this line:

https://github.com/tpope/vim-dadbod/blob/33e576f5276de5aae8a7e6741818528e189b844f/autoload/db.vim#L206

To look like this:

execute 'Start -wait=always' escape(cmd, '%#')

And then see what :DB sqlserver://... does.

tpope avatar Sep 17 '19 21:09 tpope

No change unfortunately

gilfra0000 avatar Sep 19 '19 22:09 gilfra0000

Change it to

echomsg escape(cmd, '%#')

and see what the command is. It should show up in :messages. Try running that command in a command prompt and see if it works.

tpope avatar Sep 19 '19 23:09 tpope

I've changed that line, then run the :DB sqlserver://.. command.

messages doesn't show anything that corresponds.

For what its worth the command I'm running is: ":DB sqlserver://@DESKTOP-*******/SQLEXPRESS/test"

test is the name of the database. I'm not specifying a port as the sql server is installed locally. I've also omitted the username and password to use a trusted connection - including them makes no difference.

I'm able to login using a console client called mssql-cli. With that I run the command: "mssql-cli -S DESKTOP-*******\SQLEXPRESS - E -d test"

-S precedes sql server instance name or address -E uses integrated authentication on windows. -d precedes the database name to connect to (test).

gilfra0000 avatar Sep 23 '19 18:09 gilfra0000

@tpope I'm having the same experience using the mssql jdbc driver, and vim dispatch. The escaped command resolves to sqlcmd -S '127.0.0.1' -U '<username>' -P '<password>' -d '<database_name>' for me

Parasrah avatar Jan 20 '20 20:01 Parasrah

What is :set shell?. I would expect those to be double quotes if you're using cmd.exe.

tpope avatar Jan 21 '20 09:01 tpope

shell=/bin/bash

Edit: I'm using linux btw

Parasrah avatar Jan 22 '20 16:01 Parasrah

I just noticed the original issue says Start DB .... That won't work, and the error message makes perfect sense. Use DB ....

tpope avatar Jan 22 '20 16:01 tpope

There's a lot going on here, can you describe your symptoms as if the original issue didn't exist?

tpope avatar Jan 22 '20 16:01 tpope

System

Ubuntu 18.04

NVIM v0.5.0-dev
Build type: RelWithDebInfo
Lua 5.1
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-faA9R3/neovim-0.5.0+ubuntu1+git202001222018-91bd1dd-00e710e=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim-faA9R3/neovim-0.5.0+ubuntu1+git202001222018-91bd1dd-00e710e/build/config -I/build/neovim-faA9R3/neovim-0.5.0+ubuntu1+git202001222018-91bd1dd-00e710e/src -I/build/neovim-faA9R3/neovim-0.5.0+ubuntu1+git202001222018-91bd1dd-00e710e/.deps/usr/include -I/usr/include -I/build/neovim-faA9R3/neovim-0.5.0+ubuntu1+git202001222018-91bd1dd-00e710e/build/src/nvim/auto -I/build/neovim-faA9R3/neovim-0.5.0+ubuntu1+git202001222018-91bd1dd-00e710e/build/include
Compiled by buildd@lgw01-amd64-019

Features: +acl +iconv +tui

Config

  • vim-dadbod
  • vim-dispatch

Commands

:DB g:db = jdbc:sqlserver://127.0.0.1;databaseName=<database_name>;user=<user>;password=<password>;
:DB

The above DB command, which I would expect to open an interactive shell, does nothing

Notes

I haven't had time to try this isolated (disabling other plugins). Honestly it's not that severe of an issue, I find I mostly execute a buffer which works fine. I just saw this on the repo and thought I'd offer my experience as well.

Parasrah avatar Jan 23 '20 17:01 Parasrah

Try :Start top, does that work?

tpope avatar Jan 26 '20 16:01 tpope

Start top gives me: top: failed tty get Start ls seems to work though

edit: I use the kitty terminal, echo $TERM: xterm-kitty

if this seems like an environment specific issue I'm happy to figure it out for myself

Parasrah avatar Jan 28 '20 18:01 Parasrah

It's using :! because no other adapter is available, and Neovim's :! doesn't support interactive processes. There are plans to add :terminal support to Dispatch but until that happens, you can install vim-dispatch-neovim to solve this.

tpope avatar Jan 30 '20 14:01 tpope