我正在尝试使用Pyodbc和Unix ODBC连接到安装在Ubuntu 16.04上的informix数据库,但是我收到了这个错误:
错误:('HY000','[HY000] [unixODBC] [Informix] [Informix ODBC Driver] [Informix]未指定的系统错误= -23101。( - 23101)(SQLDriverConnect)')
我正在使用这个python代码:
import pyodbc
DRIVER = 'IBM INFORMIX ODBC DRIVER'
SERVER = 'ol_informix1210'
DATABASE = 'rays'
USER='informix'
PASS='Admin123'
constr = 'DRIVER={%s};SERVER=%s;DATABASE=%s;UID=%s;PWD=%s' % (DRIVER, SERVER, DATABASE, USER, PASS)
con = pyodbc.connect(constr)
配置UnixODBC我使用了那两个配置文件: ODBC.INI:
[ODBC Data Sources]
Infdrv1=IBM INFORMIX ODBC DRIVER
Infdrv2=IBM INFORMIX ODBC DRIVER
;
; Define ODBC Database Driver's Below - Driver Configuration Section
;
[Infdrv1]
Driver=/opt/informix/lib/cli/iclit09b.so
Description=IBM INFORMIX ODBC DRIVER
Database=rays
LogonID=informix
pwd=Admin123
Servername=ol_informix1210
TRANSLATIONDLL=/opt/informix/lib/esql/igo4a304.so
[Infdrv2]
Driver=/opt/informix/lib/cli/iclis09b.so
Description=IBM INFORMIX ODBC DRIVER
Database=rays
LogonID=informix
pwd=Admin123
Servername=ol_informix1210
CursorBehavior=0
CLIENT_LOCALE=en_us.8859-1
DB_LOCALE=en_us.8859-1
TRANSLATIONDLL=/opt/informix/lib/esql/igo4a304.so;
; UNICODE connection Section
;
[ODBC]
;uncomment the below line for UNICODE connection
;UNICODE=UCS-4
;
; Trace file Section
;
UNICODE=UCS-2
Trace=0
TraceFile=/tmp/odbctrace.out
InstallDir=/opt/informix
TRACEDLL=idmrs09a.so
和odbcinst.ini:
[ODBC Drivers]
IBM INFORMIX ODBC DRIVER=Installed
[IBM INFORMIX ODBC DRIVER]
Driver=/opt/informix/lib/cli/iclit09b.so
Setup=/opt/informix/lib/cli/iclit09b.so
APILevel=1
ConnectFunctions=YYY
DriverODBCVer=03.51
FileUsage=0
SQLLevel=1
smProcessPerConnect=Y
有人知道这里的问题是什么吗?
答案 0 :(得分:0)
当我尝试通过PHP连接到notifyix DB时遇到了类似的问题。当我从shell检查环境变量时,我能够看到它们,但是当我通过info.php检查时未设置它们。
所以基本上我必须在/ etc / apache2 / envvars中对环境变量进行硬编码
之后,我可以通过终端和info.php看到env变量,并且连接正常。
我希望这可以帮助您确保正确设置环境变量。
谢谢