Pypyodbc:尝试连接SQL Server时无法打开lib'FreeTDS':找不到文件“)错误

时间:2022-09-01 15:46:37

I'm trying to connect to a SQL Server using Pypyodbc on Mac and I'm getting the following error:

我正在尝试使用Mac上的Pypyodbc连接到SQL Server,我收到以下错误:

pypyodbc.DatabaseError: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'FreeTDS' : file not found")

I have installed freeTDS and unixodbc

我已经安装了freeTDS和unixodbc

brew install unixodbc
brew install freetds

and here is my connection String with dummy data:

这是我的连接字符串与虚拟数据:

connection_String = "Driver=FreeTDS;Server=123.12.12.12;tds_version=7.2;Database=db_db;Uid=username:pwd=password:port=1433"

2 个解决方案

#1


10  

Check your /etc/odbcinst.ini or it could be under /etc/unixODBC/odbcinst.ini

检查你的/etc/odbcinst.ini或它可以在/etc/unixODBC/odbcinst.ini下

In your connection string you have something like this "DRIVER=FreeTDS" there needs to be an entry in that file like the following. You may need to change your driver location.

在您的连接字符串中,您有类似“DRIVER = FreeTDS”的内容,需要在该文件中输入如下所示的条目。您可能需要更改您的驱动程序位置。

[FreeTDS]
Description             = FreeTDS unixODBC Driver
Driver          = /usr/lib64/libtdsodbc.so.0
Setup           = /usr/lib64/libtdsodbc.so.0
UsageCount              = 1

#2


7  

First, you can use pymssql which doesn't require configuring unixODBC, which is the problem here.

首先,您可以使用不需要配置unixODBC的pymssql,这是问题所在。

To configure unixODBC with FreeTDS, do the following: http://www.unixodbc.org/doc/FreeTDS.html

要使用FreeTDS配置unixODBC,请执行以下操作:http://www.unixodbc.org/doc/FreeTDS.html

There's a tool that comes with FreeTDS, tsql. Use it to test your connection string. It's a very bare bones tool and something of a pain. :-/

FreeTDS,tsql附带了一个工具。用它来测试你的连接字符串。这是一个非常简单的骨头工具,有点痛苦。 : - /

Finally, there's a similar question with other problems in *: How do I configure pyodbc to correctly accept strings from SQL Server using freeTDS and unixODBC?

最后,与*中的其他问题有类似的问题:如何配置pyodbc以使用freeTDS和unixODBC正确接受来自SQL Server的字符串?

#1


10  

Check your /etc/odbcinst.ini or it could be under /etc/unixODBC/odbcinst.ini

检查你的/etc/odbcinst.ini或它可以在/etc/unixODBC/odbcinst.ini下

In your connection string you have something like this "DRIVER=FreeTDS" there needs to be an entry in that file like the following. You may need to change your driver location.

在您的连接字符串中,您有类似“DRIVER = FreeTDS”的内容,需要在该文件中输入如下所示的条目。您可能需要更改您的驱动程序位置。

[FreeTDS]
Description             = FreeTDS unixODBC Driver
Driver          = /usr/lib64/libtdsodbc.so.0
Setup           = /usr/lib64/libtdsodbc.so.0
UsageCount              = 1

#2


7  

First, you can use pymssql which doesn't require configuring unixODBC, which is the problem here.

首先,您可以使用不需要配置unixODBC的pymssql,这是问题所在。

To configure unixODBC with FreeTDS, do the following: http://www.unixodbc.org/doc/FreeTDS.html

要使用FreeTDS配置unixODBC,请执行以下操作:http://www.unixodbc.org/doc/FreeTDS.html

There's a tool that comes with FreeTDS, tsql. Use it to test your connection string. It's a very bare bones tool and something of a pain. :-/

FreeTDS,tsql附带了一个工具。用它来测试你的连接字符串。这是一个非常简单的骨头工具,有点痛苦。 : - /

Finally, there's a similar question with other problems in *: How do I configure pyodbc to correctly accept strings from SQL Server using freeTDS and unixODBC?

最后,与*中的其他问题有类似的问题:如何配置pyodbc以使用freeTDS和unixODBC正确接受来自SQL Server的字符串?