Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ms sql adaptor string #49

Open
gilfra0000 opened this issue Aug 31, 2019 · 22 comments
Open

ms sql adaptor string #49

gilfra0000 opened this issue Aug 31, 2019 · 22 comments

Comments

@gilfra0000
Copy link

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.

@tpope
Copy link
Owner

tpope commented Sep 3, 2019

Do you have dispatch.vim installed?

@gilfra0000
Copy link
Author

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

@gilfra0000
Copy link
Author

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

@tpope
Copy link
Owner

tpope commented Sep 5, 2019

What is happening?

@gilfra0000
Copy link
Author

  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;

@tpope
Copy link
Owner

tpope commented Sep 6, 2019

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

@gilfra0000
Copy link
Author

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.

@tpope
Copy link
Owner

tpope commented Sep 8, 2019

What if you call :Start cmd.exe?

@gilfra0000
Copy link
Author

  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.

@tpope
Copy link
Owner

tpope commented Sep 17, 2019

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

silent execute 'Start' escape(cmd, '%#')

To look like this:

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

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

@gilfra0000
Copy link
Author

No change unfortunately

@tpope
Copy link
Owner

tpope commented Sep 19, 2019

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.

@gilfra0000
Copy link
Author

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).

@Parasrah
Copy link

@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

@tpope
Copy link
Owner

tpope commented Jan 21, 2020

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

@Parasrah
Copy link

Parasrah commented Jan 22, 2020

shell=/bin/bash

Edit: I'm using linux btw

@tpope
Copy link
Owner

tpope commented Jan 22, 2020

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

@tpope tpope closed this as completed Jan 22, 2020
@tpope tpope reopened this Jan 22, 2020
@tpope
Copy link
Owner

tpope commented Jan 22, 2020

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

@Parasrah
Copy link

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.

@tpope
Copy link
Owner

tpope commented Jan 26, 2020

Try :Start top, does that work?

@Parasrah
Copy link

Parasrah commented Jan 28, 2020

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

@tpope
Copy link
Owner

tpope commented Jan 30, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants