【发布时间】:2021-02-15 08:28:38
【问题描述】:
我正在尝试连接到一个旧数据库,该数据库具有自己的同样旧的 ODBC 驱动程序(不再维护)
# The driver is 32 bit, so I'm using Python 3.8.7 (32bit)
con = pyodbc.connect(r"Driver={CSI RBM 4.02 ODBC Driver};Dbq=" + database_path + ";Server=localhost")
但是我收到了这个错误:
[08001] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
根据https://knowledgebase.progress.com/articles/Article/000033360表示:
This error indicates that an application requested ODBC 3.x behavior however the driver was only ODBC 2.x compliant.
我假设这意味着 Python 或 Pyodbc 使用的是 ODBC 3.x,而驱动程序使用的是 2.x。
所以,如果我假设所有这些都是正确的,那么我的问题是 我如何强制 Pyodbc 使用 ODBC 2.x,或者有没有其他方法可以使用 Python 连接到这个数据库?
任何其他有用的信息也将不胜感激
【问题讨论】:
-
是的,pyodbc 确实调用了
SQLSetEnvAttr并指定了SQL_OV_ODBC3。如果您使用的是 Windows,那么您可以尝试使用 ADODB(例如,通过 VBScript)来查看是否可以通过这种方式建立连接。 -
是的,我在 Windows 上。你认为 ADODB 和 VBScript 是唯一的方法吗?理想情况下,我想保留在 Python 中,但如果需要,我会考虑这个
-
不一定是唯一的方法,只是一种快速测试 pyodbc 以外的东西是否可以与该驱动程序一起使用的方法。
标签: python database odbc pyodbc