python - Web2py 与 DB2 配合使用

标签 python db2 web2py pyodbc unixodbc

有人知道如何使用远程 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/

相关文章:

python - 如何在 python 中的数据文件中将数组作为列元素写入并稍后在 C 中读取?

python - 使用自定义 RNN 层说明自定义模型中缺少参数

python - Pandas 错误 : "IndexError: iloc cannot enlarge its target object"

java - com.ibm.db2.jcc.am.SqlTransactionRollbackException : DB2 SQL Error: SQLCODE=-911, SQLSTATE=40001,SQLERRMC=68,DRIVER=3.65.110

java - 如何识别 DB2 端口号

html - web2py - 如何将带有 {{block ...}} 的 html 插入到另一个 html 中?

python - subprocess.Popen 和缓冲进程输出

db2 - SQLCODE:-420,SQLSTATE:22018,SQLERRMC:BIGINT

python - web2py 链接到 CSS

python - Web2py 票证无效链接