× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Here you go:

from xlsxwriter import Workbook
import ibm_db_dbi as dbi

conn = dbi.connect('DATABASE=*LOCAL')

cur = conn.cursor()
cur.execute("select * from qiws.qcustcdt")
headers = [descr[0] for descr in cur.description]

with Workbook('qcustcdt.xlsx') as workbook:
worksheet = workbook.add_worksheet()
worksheet.write_row('A1', headers)
for i, row in enumerate(cur, start=1):
worksheet.write_row(i, 0, row)

"OpenSource" <opensource-bounces@xxxxxxxxxxxx> wrote on 07/06/2016
02:59:05 PM:

From: Jack Callahan <jjcllhn@xxxxxxxxx>
To: opensource@xxxxxxxxxxxx
Date: 07/07/2016 10:19 AM
Subject: [IBMiOSS] IBM i python ibm_db_dbi example usage
Sent by: "OpenSource" <opensource-bounces@xxxxxxxxxxxx>

I'd like to be able to create a python3 script that runs locally on an
IBMi, reads a DB2 table and writes an .xlsx spreadsheet to the IFS.

I've got python3 installed via 5733-OPS option 2, and used pip3 to set
up
ibm_db and xlsxwriter.

Can anyone point me to a decent example that connects to the local IBMi
DB2
using ibm_db_dbi, and iterates over the result set? Looking for help
mapping the connect method parameters.

John Yueng provided a nice example for iSeriesPython on his blog, but
that
uses db2 rather than ibm_db
http://iseriespython.blogspot.ca/2013/05/copy-physical-file-to-
excel-in-9-lines.html
.
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/opensource.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.