0

I am trying to connect to NZ db from python using NZPY.

conn = nzpy.connect(user="DEV_USR", host="bac-nettezza", port =5480,database="DEV",securityLevel=1,logLevel=0)
with conn.cursor() as cursor:
    try:
        cursor.execute("select * from DEV.DEV_USR.abc")
    except Exception as e:
        print(str(e))

This gives me

File "/usr/local/lib/python3.6/site-packages/nzpy/__init__.py", line 50, in connect
    application_name, max_prepared_statements, datestyle, logLevel, tcp_keepalive,char_varchar_encoding, logOptions, pgOptions)
  File "/usr/local/lib/python3.6/site-packages/nzpy/core.py", line 1538, in __init__
    raise ProgrammingError("Error in handshake")
nzpy.core.ProgrammingError: Error in handshake

The user is able to connect to NZ from unix without a password (that was the decision made so we don't have to provide password in the script).

Please suggest what can be done here. TIA

John Gordon
  • 29,573
  • 7
  • 33
  • 58
Sparkles
  • 61
  • 2
  • 6
  • Are you sure `host="bac-nettezza"` is correct? I would have expected there to be some periods on that hostname, i.e. something like `bac-nettezza.mycompany.com` I suppose the bare hostname might be ok if your machine is on the same peer network... Is it? – John Gordon Jul 14 '23 at 02:23
  • Yes, I was able to connect to the same database with a different username and password but this usr was created to avoid giving password in the script. – Sparkles Jul 14 '23 at 02:27

1 Answers1

2

Netezza connection is TLS secured by default. This error is coming for the securityLevel 1 which represent Only Unsecured session causing the handshake error.

You can use a secured securityLevel like 0,2,3. Security levels used in nzpy are listed below.

0: Preferred Unsecured session

1: Only Unsecured session

2: Preferred Secured session

3: Only Secured session

dlmeetei
  • 9,905
  • 3
  • 31
  • 38
Arnab Das
  • 21
  • 1