[英]Exporting data from DB2 using Python
您可以使用 Python 模块 pandas。 有一个堆栈溢出答案显示如何将Db2 结果集加载到 pandas DataFrame 中。 pandas 具有内置的 function to_excel()允许通用 xlsx 文件。
If you want to run the Python script on the Db2 server but download it to a local machine, you can take a look into my blog how to use the function to generate in-memory Excel or CSV files .
所以这是非常简洁的代码,查询本身缺失:
# read the Db2 result set into a DataFrame
df = pd.read_sql(sql, conn)
# write out to Excel file
df.to_excel('your_data.xslx', sheet_name='Sheet1')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.