有人知道如何使用远程 DB2 服务器在 Linux 上运行 Web2py 吗?
我尝试使用 pyodbc,但它的文档非常差
我找不到它的分步指南。
我的配置文件:
odbcinst.ini:
[DB2]
Description = DB2 Driver
Driver = /opt/odbc_cli/clidriver/lib/libdb2.so
FileUsage = 1
DontDLClose = 1
odbc.ini
[test]
Description = Test to DB2
Driver = DB2
尝试连接:
>>> import pyodbc
>>> cnxn = pyodbc.connect('DRIVER={DB2};SERVER=172.16.1.35;DATABASE=log10;UID=db2admin;PWD=passs')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.Error: ('08001', '[08001] [unixODBC][IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "127.0.0.1". Communication function detecting the error: "connect". Protocol specific error code(s): "111", "*", "*". SQLSTATE=08001\n (-30081) (SQLDriverConnect)')
我错过了什么?
提前致谢
克里斯蒂安
最佳答案
这是一个典型的通信问题错误。 连接之前,请尝试检查连接情况:
实例端口是什么?默认值为 50000,但您没有在 connect 语句中指定。
IP 地址/主机名是什么?如果你的情况似乎是 172.16.1.35
在该端口尝试 telnet
telnet 172.16.1.35 50000
如果可以建立连接,您将收到如下消息:
Trying 172.16.1.35...
Connected to hostname.
Escape character is '^]'.
如果您遇到连接问题,您会看到
Trying 172.16.1.35...
telnet: Unable to connect to remote host: Connection refused
据我所知,您必须在执行程序之前检查实例端口和连接设置。 可能是防火墙问题,检查一下开放的端口吗? 在服务器中尝试 netstat -nato,查看 DB2 实例是否处于事件状态并监听端口(当前未知)
关于python - Web2py 与 DB2 配合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12648480/