Question

I have the following code:

import pyodbc
cnxn = pyodbc.connect('DRIVER={IBM DB2 ODBC DRIVER};DATABASE=TDB2;UID=username;PWD=password')

I get the error message SQLSTATE=42705, which means that it cannot reach the database.

When I connect to DB2 using AQT, it states that the Database Name is DB2, Data Source Name is TDB2, DBALIAS=TDB2, ODBC driver is DB2CLI.DLL. Inside the database, I have some kind of "containers", which are listed in the category of "Database Objects", the containers contain Tables, and I believe that I need to specify this in my connection string as well.

I am completely confused about this. I do not even understand how AQT can connect to the database, without me providing an IP address, nor port number.

Was it helpful?

Solution

The solution was to remove the DATABASE=TDB2 and replace it with DBALIAS=TDB2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top