vim-dadbod
vim-dadbod copied to clipboard
ms sql adaptor string
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.
Do you have dispatch.vim installed?
Hello, I did not, but I have just installed it.
To clarify I have installed it and hoping for further guidance. Thank you for taking the time.
What is happening?
-
I run the vim command:
Start DB sqlserver://username:password@host/database -
The command as it appears on the command line gets changed to:
:DB! sqlserver://username:password@host/database (windows/?) -
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...
- 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;
Don't run :Start DB, run :DB and it will invoke :Start for you.
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.
What if you call :Start cmd.exe?
-
The command on the command line changes to
!cmd.exe (windows/?. -
A console window pops opens (
C:\WINDOWS\SYSTEM32\cmd.exe) It shows a command prompt.
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.
No change unfortunately
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.
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).
@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
What is :set shell?. I would expect those to be double quotes if you're using cmd.exe.
shell=/bin/bash
Edit: I'm using linux btw
I just noticed the original issue says Start DB .... That won't work, and the error message makes perfect sense. Use DB ....
There's a lot going on here, can you describe your symptoms as if the original issue didn't exist?
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.
Try :Start top, does that work?
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
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.