我正在使用pyodbc
来管理我的数据库连接。我试图连接到OSI PI数据库,并收到此错误:如何将Python 2.6连接到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()
有没有人连接到OSI PI的Python?如果是这样,你是怎么做到的?如果不是,并且您仍然使用OSI数据库中的数据,那么最终如何访问它?
我有使用'R'' RODBC'软件包连接到PIODBC的问题。症状是所有查询返回零行。解决的办法是设置'RODBC'一次获取一行('rows_at_time = 1')以及('believeNRows = FALSE'),因为PI ODBC驱动程序搞乱了行数。 http://stackoverflow.com/q/7425100/176995 – 2012-06-12 00:52:13