如何在Mac OSX上使用Vim dbext连接到MS SQLServer?

| 我使用MacVim和dbext插件连接到Oracle,它运行良好。现在我需要连接到MS SQLServer, 但显示错误:
Connection: T(SQLSRV)  H(localhost)  U(user)   at 14:38
/bin/bash: osql: command not found
有人知道怎么做吗?     
已邀请:
确保您具有FreeTDS CLI程序之一。我认为tsql比osql具有更全面的功能,但相同的方法应适用于任何一种。 创建一个外壳脚本来包装tsql。将其放在您的路径中。 然后将dbext配置值添加到您的.vimrc
\" I\'m using mssql.sh as the wrapper program. 
\" Re-title to whatever you name yours

let g:dbext_default_SQLSRV_bin = \"mssql.sh\"

\" FreeTDS options for osql/tsql are not as feature rich as dbext expects

let g:dbext_default_SQLSRV_cmd_options = \' \'

\" set \'host\' in you profile to the FreeTDS server config, which will be altered in the script
我打过的包装纸没什么特别的,但是经过测试可以正常工作。
#!/bin/bash

# -S is better for FreeTDS then -H
options=$( echo $@ | sed -e \'s/-H /-S /\' -e \'s/ -i.*//\' )
# osql/tsql in freetds don\'t seem to accept a file flag
sql_scratch=$( echo $@ | sed \'s|^.* -i||\' )
# and execute...
cat $sql_scratch | tsql $options
    
Osql随FreeTDS库一起提供,但是可能会提示另一个错误:\“非法选项-w \”。 您可以在DBEXT连接的type参数中使用ODBC而不是SQLSRV。 (另一个选择是使用DBI perl接口) 安装iodbc并使用--with-iodbc选项构建freetds。 编辑您的odbc.ini文件,您可以使用iodbc-config --iodbcini或找到-name odbc.ini / |找到它。 grep odbc.ini。 我正在工作的odbc.ini(请注意文件名,在freebsd框中的即时消息):
[MYDNSNAME]
Driver          = /usr/local/lib/libtdsodbc.so
Description     = Sample OpenLink MT DSN
Server          = 192.168.100.4
Port            = 50436
TDS_Version     = 8.0
Database        = initial_db
ServerOptions   = 
ConnectOptions  = 
Options         = 
ReadOnly        = no
而我在.vimrc上的dbext连接:
let g:dbext_default_profile_CONN = \'type=ODBC:dsnname=MYDSNNAME:user=domain\\user:passwd=pass:dbname=initial_db\'
    
您还可以将DBExt配置为使用更丰富的sqsh代替freetds中的osql程序。可以在
:h dbext
中通过搜索\“ sqsh \”找到执行此操作的示例连接配置文件。您当然应该已经可以使用sqsh了。     

要回复问题请先登录注册