帅帅的噗通
2020-01-19 15:32
浏览 693

Python3使用ibm-db 连接DB2 执行sql 时报错 SQLCODE=-332 ?

Python3使用ibm-db 连接DB2 执行sql 时报错 SQLCODE=-332 codepage转换错误,现在不能修改DB2 server的设置,请问怎么解决?
代码如下:

import ibm_db


conn=ibm_db.connect("DATABASE=db;HOSTNAME=host;PORT=60000;PROTOCOL=TCPIP;UID=user;PWD=pwd",'','')
sql = "SELECT * FROM T_PATENTINFO"
stmt = ibm_db.exec_immediate(conn, sql)
result = ibm_db.fetch_tuple(stmt)
print(result)

错误信息:

Traceback (most recent call last):
  File "C:\Users\xux\AppData\Local\Programs\Python\Python37\lib\site-packages\ibm_db_dbi.py", line 1434, in _fetch_helper
    row = ibm_db.fetch_tuple(self.stmt_handler)
 SQLCODE=-332

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/PythonRepo/patent/db_fixture/ibm_db_connect.py", line 53, in <module>
    rresult = DB().search_patent()
  File "C:/PythonRepo/patent/db_fixture/ibm_db_connect.py", line 44, in search_patent
    result = self.cursor.fetchone()
  File "C:\Users\xux\AppData\Local\Programs\Python\Python37\lib\site-packages\ibm_db_dbi.py", line 1460, in fetchone
    row_list = self._fetch_helper(1)
  File "C:\Users\xux\AppData\Local\Programs\Python\Python37\lib\site-packages\ibm_db_dbi.py", line 1441, in _fetch_helper
    raise self.messages[len(self.messages) - 1]
 SQLCODE=-332
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

相关推荐 更多相似问题