开发者

DB2 connection string problem

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. 开发者_StackOverflow社区I do not even understand how AQT can connect to the database, without me providing an IP address, nor port number.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜