gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 09:56:12 30 4
gpt4 key购买 nike

我使用 MacVim 和 dbext 插件连接到 Oracle,它运行良好。现在我需要连接到 MS SQLServer,但它显示错误:

连接:T(SQLSRV) H(localhost) U(user) 在 14:38
/bin/bash: osql: 找不到命令

有人知道怎么做吗?

最佳答案

确保您拥有 FreeTDS CLI 程序之一。我认为 tsql 比 osql 功能更全面,但同样的方法应该适用于两者。

创建一个shell脚本来包装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

关于sql-server - 如何在 Mac OSX 上使用 Vim dbext 连接到 MS SQLServer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5659687/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com