RODBC :: ODBCLISTDRIVERS()不列出/opt/homebrew/etc/odbcinst.ini

问题描述 投票:0回答:3
brew install unixodbc

然后,我尝试按建议在

https://db.rstudio.com/best-practices/drivers/drivers/

上安装Freetds驱动程序。
# SQL Server ODBC Drivers (Free TDS)
  brew install freetds --with-unixodbc
我收到错误:

Error: invalid option: --with-unixodbc

i我发现了一个消息来源,说该选项不再可用,因为现在默认是默认值。因此,我跑了:
brew install freetds

在R Studio(和R)我然后尝试列出已安装的驱动程序,但找不到:
> odbc::odbcListDrivers()
[1] name      attribute value    
<0 rows> (or 0-length row.names)

next我尝试安装SQL Server(MACOS)的Microsoft ODBC驱动程序,该驱动程序是根据
Https://learn.microsoft.com/en-en-us/sql/connect/connect/linux-mac/install-microsoft-microsoft-microsoft-microsoft-odbc-driver -sql-server-macos?view = sql-server-ver15
,并在

https://db.rstudio.com/databases/microsoft-sql-server/

上推荐。
我跑了:

brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release brew update HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=Y brew install msodbcsql17 mssql-tools 要检查该驱动程序是否已在odbcinst.ini文件中注册,我首先运行: odbcinst -j

结果:

unixODBC 2.3.9 DRIVERS............: /opt/homebrew/etc/odbcinst.ini SYSTEM DATA SOURCES: /opt/homebrew/etc/odbc.ini FILE DATA SOURCES..: /opt/homebrew/etc/ODBCDataSources USER DATA SOURCES..: /Users/Gina/.odbc.ini SQLULEN Size.......: 8 SQLLEN Size........: 8 SQLSETPOSIROW Size.: 8
驱动程序已经在/opt/homebrew/etc/odbcinst.ini

中注册

view /opt/homebrew/etc/odbcinst.ini
文件内容(注意freetds驱动程序似乎不存在):

[ODBC Driver 17 for SQL Server] Description=Microsoft ODBC Driver 17 for SQL Server Driver=/opt/homebrew/lib/libmsodbcsql.17.dylib UsageCount=1
在rstudio中,我再次尝试列出驱动程序,没有找到:

> odbc::odbcListDrivers() [1] name attribute value <0 rows> (or 0-length row.names)
我尝试了更多的事情,包括:

复制/opt/homebrew/etc/odbcinst.ini的内容到用户级文件/users/gina/.odbcinst.ini

已编辑/opt/homebrew/etc/odbc.ini文件(以前是空的)以包含连接详细信息(尽管我计划只在dbi :: dbConnect命令中指定这些详细信息)。新的编辑文件内容:

[ODBC Driver 17 for SQL Server] Driver = ODBC Driver 17 for SQL Server Servername = servername.net Database = databasename UserName = rstudioapi::askForPassword("Database user") Password = rstudioapi::askForPassword("Database password") Port = 1433

  1. 复制/opt/homebrew/etc/odbc.ini的内容到用户级文件/gina/.odbc.ini

  2. 设置环境变量:

     export ODBCSYSINI=/opt/homebrew/etc
    
  3. 注意,当我运行时:

  4. odbcinst -q -s
  5. 发现了驱动程序:

    [ODBC Driver 17 for SQL Server]
    
  6. ,似乎ODBC :: ODBCLISTDRIVERS()应该能够找到驱动程序。任何想法或建议都将不胜感激!谢谢!

Edit: 我还尝试使用新的连接按钮,有趣的是,我的驱动程序已在那里列出!

新连接窗口

,但是,当我单击它并单击测试时,我会收到一个错误:

Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Data source name not found and no default driver specified 

带错误的驱动器连接窗口

当我尝试时,我会遇到相同的错误: isql -v ODBC Driver 17 for SQL Server myusername mypassword [IM002][unixODBC][Driver Manager]Data source name not found and no default driver specified

Edit2: 我将数据源名称(ODBC.ini文件中的顶行)更改为“ SQLSever”,然后将Servername参数更改为服务器(我在系统级文件和用户级文件中都这样做)。现在,当我运行以下命令时,它试图连接(尽管遇到了一个新错误)。

isql -v SQLServer myusername mypassword [08001][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [OpenSSL library could not be loaded, make sure OpenSSL 1.0 or 1.1 is installed] [08001][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection [ISQL]ERROR: Could not SQLConnect
不幸的是,我仍然无法在R中连接。我得到了与以前相同的错误。
注意,ISQL命令似乎使用系统级文件,而RSTUDIO使用用户级别文件。这些文件在两个地方都是相同的。

我在有关类似问题的帖子中阅读了M1 Mac有此问题,但非M1 Mac却没有。因此,我尝试在旧的MacBook Pro上重复整个过程,但没有遇到问题! ODBC :: ODBCLISTRIVERS()在安装SQL Server(MACOS)的Microsoft ODBC驱动程序后立即列出了驱动程序。我不需要编辑或创建任何文件。

具有M1 Mac I能够通过将OpenSSL文件夹更改为旧版本,可以通过终端连接到SQL Server。驱动程序安装openssl@3(opt/homebrew/opt/openssl@3),但实际上您需要使用
[电子邮件保护]
代替。 我在终端中遵循的步骤是:

brew install [email protected] rm /opt/homebrew/opt/openssl ln -s /opt/homebrew/Cellar/[email protected]/1.1.1l_1 /opt/homebrew/opt/openssl
这将创建一个符号链接“ OpenSSL”,并将其指向OPT/Homebrew/Cellar/cellar/cellar/

[电子邮件保护]

文件夹中的正确文件(1.1.1L_1)。 在创建符号链接之前,请使用opt/homebrew/cellar/

[电子邮件保护]

/1.1.1l_1
r sql-server odbc unixodbc
3个回答
2
投票

对于Intel Mac(Ventura)和r 4.3.1上的MMSSQL驱动程序安装


1
投票
按照macosaarch64

posit指令,我编辑了.renviron文件(nano /Users/<username>/.Renviron)以添加行:ODBCSYSINI=/etc

我知道
/etc

文件夹包含一个符号链接,因为我创建了Symlink原始文章中的故障排除步骤。

restartrstudio. 现在/usr/local/etc/odbcinst.ini

列出了与
    odbc::odbcListDrivers()
  1. 的相同驱动程序。
    驱动程序路径(
  2. /usr/local/etc/odbcinst.ini
)中的just sub进入您的符号链接路径:即
/opt/homebrew/etc/
),我怀疑它应该在不需要复制任何文件的情况下工作。
    
this解决方案为我工作:
  1. 创建两个符号链接:


    ODBCSYSINI=/opt/homebrew/etc/

    
    
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.