DB2连接字符串问题
我有以下代码:
import pyodbc
cnxn = pyodbc.connect('DRIVER={IBM DB2 ODBC DRIVER};DATABASE=TDB2;UID=username;PWD=password')
我收到错误消息 SQLSTATE=42705,这意味着它无法到达数据库。
当我使用 AQT 连接到 DB2 时,它指出数据库名称是 DB2,数据源名称是 TDB2,DBALIAS=TDB2,ODBC 驱动程序是 DB2CLI.DLL。在数据库内部,我有某种“容器”,它们列在“数据库对象”类别中,容器包含表,我相信我也需要在连接字符串中指定它。
我对此完全困惑。我什至不明白 AQT 如何在没有提供 IP 地址或端口号的情况下连接到数据库。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是删除 DATABASE=TDB2 并将其替换为 DBALIAS=TDB2。
The solution was to remove the DATABASE=TDB2 and replace it with DBALIAS=TDB2.