我pyodbc
用来管理我的数据库连接。我正在尝试连接到 OSI PI 数据库并收到此错误:
pyodbc.Error: ('IM002', "[IM002] [OSI][PI ODBC][PI]PI-API Error <pilg_getdefserverinfo> 0 (0) (SQLDriverConnectW); [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr). (0)")
在与供应商交谈后,我得到了以下回复:
Looks like pyodbc is written against ODBC 3.x. The OSI PI ODBC driver is using ODBC 2.0. The python ODBC driver manager will convert most ODBC 3 calls on the fly to ODBC 2 ones. Anything added to 3, however, will obviously fail. You would need to find some way to make sure that your only using 2.0 compliant ODBC calls. Currently their is not a PI ODBC driver that is compliant with ODBC 3.0.
我的代码相当简单,因为此时我只是尝试连接:
import pyodbc
constr = 'DRIVER={PI-ODBC};SERVER=myserver;UID=MY_UID'
pyodbc.pooling=False
conn = pyodbc.connect(constr) # Error at this line
conn.close()
有没有人将 python 连接到 OSI PI?如果是这样,你是怎么做到的?如果不是,并且您仍然使用 OSI 数据库中的数据,您最终是如何访问它的?