gpt4 book ai didi

freetds - FreeTDS 和 unixodbc 的区别?

转载 作者:行者123 更新时间:2023-12-04 06:58:26 57 4
gpt4 key购买 nike

我试图弄清楚这两个拼图在连接到 Linux 上的 MS-SQL 服务器时如何交互和组合在一起。

据我了解,FreeTDS 是用于与 MS-SQL 对话的协议(protocol)(即一组规则),它是真正进行对话的东西。 Unixodbc 是一个实现 ODBC API 的驱动程序,即实现了我猜的一组函数。

为什么这两件事都是必要的?谁能详细说明我对这两件事的实际作用的粗略理解?

最佳答案

unixODBC是 ODBC 的“DriverManager”。您可以使用 unixODBC在 Linux 或 *nix 系统上连接到任何支持 ODBC 的数据库时。这样做意味着您可以编写大量的数据库查询,您应该能够在不同的数据库之间使用这些查询。如果您不在 Unix 上,您将使用不同的驱动程序管理器,例如内置的 MS Office 驱动程序管理器。
为了使所有组件清晰:如果您使用一种语言,比如说 Python,来连接到 SQL Server,您的连接可能从 Python 的 pyodbc(将 python 对象与 unixODBC 相互转换)传递到 unixODBC(管理驱动程序,例如FreeTDS)到 FreeTDS(将 unixODBC 对象与 Microsoft 支持的 TDS 协议(protocol)相互转换)到 SQL Server。unixODBC网站 http://www.unixodbc.org/说:

An ODBC application makes ODBC calls to the DriverManager. The DriverManager carries out a number of tasks for the application such as:

  • ensuring the proper driver is loaded/unloaded
  • validation tasks
  • 3.5 to 3.0 to 2.0 call and data mapping

Most calls to the DriverManager get passed onto the loaded Driver to be further processed but that is of little concern to the application.

Some advantages to using an ODBC DriverManager include:

  • portable data access code
  • runtime binding to a Data Source
  • ability to easily change the Data Source

简而言之,是驱动程序管理器读取您的 DSN,查看配置的数据源,并决定连接的位置和方式。
根据您使用的数据库,您将需要不同的驱动程序。这段代码将您使用 ODBC 发出的请求“翻译”为相关数据库管理系统的正确协议(protocol)。对于不同的数据源,这是需要不同的组件。在您的情况下,TDS 是 MS SQL Server 使用的协议(protocol)。 FreeTDS 是该协议(protocol)的免费软件实现。
另见维基百科 https://en.wikipedia.org/wiki/Open_Database_Connectivity (重点保留):

ODBC accomplishes DBMS independence by using an ODBC driver as a translation layer between the application and the DBMS. The application uses ODBC functions through an ODBC driver manager with which it is linked, and the driver passes the query to the DBMS. An ODBC driver can be thought of as analogous to a printer driver or other driver, providing a standard set of functions for the application to use, and implementing DBMS-specific functionality. An application that can use ODBC is referred to as "ODBC-compliant". Any ODBC-compliant application can access any DBMS for which a driver is installed. Drivers exist for all major DBMSs, many other data sources like address book systems and Microsoft Excel, and even for text or CSV files.

关于freetds - FreeTDS 和 unixodbc 的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31980980/

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