Suraj Nagabhushana Suraj Nagabhushana - 1 month ago 21
Python Question

Connection error using pyodbc for netezza

I am trying to connect to a netezza server. This is the code I have

import pyodbc

conn = pyodbc.connect("DRIVER={NetezzaSQL};SERVER=<Server name>;PORT=<no>;DATABASE=<dbname>;UID=user_id;PWD=password;DSN=NZSQL")

print("Connection complete")


My odbc.ini file is:

[NZSQL]
Driver32=C:\windows\SysWOW64\nsqlodbc.dll
[ASTEST]
Driver32=C:\windows\SysWOW64\cwbodbc.dll
[ODBC 32 bit Data Sources]
NZSQL=NetezzaSQL (32 bit)
ASTEST=iSeries Access ODBC Driver (32 bit)
ASPROD=iSeries Access ODBC Driver (32 bit)
[ASPROD]
Driver32=C:\windows\SysWOW64\cwbodbc.dll


My odbcinst.ini file is:

[IBM DB2 ODBC DRIVER - TACOM32 (32 bit)]
Driver=C:\PROGRA~2\QUESTS~1\TOADDA~1.2\SQLLIB\BIN\DB2CLI.DLL
Setup=C:\PROGRA~2\QUESTS~1\TOADDA~1.2\SQLLIB\BIN\DB2ODBC.DLL
32Bit=1
[ODBC 32 bit Drivers]
IBM DB2 ODBC DRIVER - TACOM32 (32 bit)=Installed
MySQL ODBC 5.1 Driver (ToadDataPoint3.8) (32 bit)=Installed
[MySQL ODBC 5.1 Driver (ToadDataPoint3.8) (32 bit)]
Driver=C:\Program Files (x86)\Dell\Toad Data Point 3.8\Plugins\MySQL\ODBC\lib\myodbc5.dll
Setup=C:\Program Files (x86)\Dell\Toad Data Point 3.8\Plugins\MySQL\ODBC\lib\myodbc5S.dll


But it gives me the following error:

pyodbc.Error: ('08001', '[08001] Client unable to establish connection (12) (SQLDriverConnect)')


I don't understand this error. Is this a netezza error or is my connect statement wrong? Thank you in advance! :)

Answer

Turns out it was a server issues. When python was trying to connect to the server, it had some issue. The same code worked fine the next day. It did say client unable to establish connection.