jaydebeapi 目前只支持到JPype1 0.6.3,安装0.7.*版本会导致无法运行。
1. pip install JPype1-0.6.3-cp37-cp37m-win_amd64.whl
2. 再将db2jcc4-10.5.9.jar包和test.py文件放在同一目录下
3. test.py文件完整代码
import os
import jaydebeapi
conn_src = jaydebeapi.connect('com.ibm.db2.jcc.DB2Driver', 'jdbc:db2://DB2_IP:50000/MAXIMO', ['db2inst1', 'maximoqa'], 'db2jcc4-10.5.9.jar')
cursor=conn_src.cursor()
sql = 'SELECT * FROM TEST'
cursor.execute(sql)
print("fetchall:")
result = cursor.fetchall()
for r in result:
print(r)
1