2
votes

I'm trying to connect to my informix database installed on Ubuntu 16.04 with Pyodbc and Unix ODBC but I'm getting this error:

Error: ('HY000', '[HY000] [unixODBC][Informix][Informix ODBC Driver][Informix]Unspecified System Error = -23101. (-23101) (SQLDriverConnect)')

I'm using this python code:

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)

to configure UnixODBC I used those two configuration file: 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

and 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

Does any one know what's the issue here ?

1
Umm.. have you set the INFORMIXDIR environment variable? In your case it should be set to INFORMIXDIR=/opt/informix. You also will need LD_LIBRARY_PATH=$INFORMIXDIR/lib:$INFORMIXDIR/esql:$INFORMIXDIR/cli - jsagrera
Thank you for your answer: Yes I've already done that - fadhloun anis
And that still fails? "Unspecified System" basically means the driver (which was loaded because you can see the "[Informix][Informix ODBC Driver]" header in the error can't find the error message for the -23101 error number. Basically it can't find the messages files in $INFORMIXDIR/msg - jsagrera
Yes, but $INFORMIXDIR is well set, because I can access to my data base throw the terminal ... but I only can't thrw the ODBC connection - fadhloun anis
One explanation of the error is -23101: Unable to load locale categories. — An invalid locale name was supplied for the locale initialization. The environment variable specifying the locale category has a wrong value. — Check the value of the corresponding environment variable, CLIENT_LOCALE or DB_LOCALE. . It can also mean that INFORMIXDIR is not set correctly — the $INFORMIXDIR/gls directory does not contain the right information. - Jonathan Leffler

1 Answers

0
votes

I ran into similar problems when I tried to connect to informix DB via PHP. When I checked the environment variables from shell, I was able to see them but they were not set when I checked via info.php

So basically I had to hard code the environment variables in /etc/apache2/envvars

After that I was able to see the env variables both via terminal and info.php and the connection worked.

I hope this could help you ensure you have set the env variables correctly.

Thanks