02-12-2020 08:58 AM - edited 02-12-2020 09:30 AM
I'd like to pull out data from the CCX database with a Python library. AFAIK, the only way to do this is connecting via custom software (e.g., Python) to the CCX's Informix.
After installing the Informix Client SDK and pyodbc (a Python library for ODBC connection), I run the following connection:
pyodbc.connect('SERVICE=1504;PROTOCOL=onsoctcp;CLIENT_LOCALE=en_US.UTF8;DB_LOCALE=en_US.UTF8;DRIVER={IBM INFORMIX ODBC DRIVER (64-bit)};UID=uccxhruser;PWD=my_pwd;DATABASE=db_cra;HOST=my-uccx;SERVER=my-uccx_uccx')
But I get the following error:
Error: ('HY000', '[HY000] [Informix][Informix ODBC Driver][Informix]INFORMIXSERVER does not match either DBSERVERNAME or DBSERVERALIASES. (-761) (SQLDriverConnect)')
Googling around, it looks like there could be something wrong in the server parameter (i.e., the name of the informix server). Is there a way to check this value in the CCX?
However, apart from this approach, is there another way to use an external python software to pull data out from the CCX box? If I cannot fix this, I can use that alternative as a reasonable fallback.
Solved! Go to Solution.
02-13-2020 12:58 AM - edited 02-13-2020 01:00 AM
Turned out that the problem was related to the server name that was my_uccx_uccx instead of my-uccx_uccx. Server names should not include dashes.
Hope this can help someone else out there! : )
02-13-2020 12:58 AM - edited 02-13-2020 01:00 AM
Turned out that the problem was related to the server name that was my_uccx_uccx instead of my-uccx_uccx. Server names should not include dashes.
Hope this can help someone else out there! : )
02-13-2020 09:25 AM
02-14-2020 02:37 AM - edited 02-19-2020 02:02 AM
Oh, ok, sure @Anthony Holloway! To make the things work fine, I built a docker container with the ODBC driver inside it (for Linux, in my case) but, if you prefer, you can also work inside a common OS environment (Windows, Linux, MacOS, ...). Of course, you need also python and pyodbc. Once you are up & running, you can just exploit pyodbc. Here is an example:
import pyodbc
pyodbc.connect('SERVICE=1504;PROTOCOL=onsoctcp;CLIENT_LOCALE=en_US.UTF8;DB_LOCALE=en_US.UTF8;DRIVER={IBM INFORMIX ODBC DRIVER (64-bit)};UID=uccxhruser;PWD=my_pwd;DATABASE=db_cra;HOST=my-uccx;SERVER=my_uccx_uccx')
conn.setdecoding(pyodbc.SQL_WCHAR, encoding='utf-8') conn.setencoding(str, encoding='utf-8') conn.setencoding(unicode, encoding='utf-8', ctype=pyodbc.SQL_CHAR) cursor = conn.cursor()
cursor.execute("select FIRST 10 * from dialinglisthistory")
# ...and there you go!
rows = cursor.fetchall()
Here you can find more details about it:
Hope this helps!
02-14-2020 07:26 AM
02-14-2020 07:32 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide