|
On Mar 7, 2017, at 2:26 PM, Buck Calabro <kc2hiz@xxxxxxxxx <mailto:kc2hiz@xxxxxxxxx>> wrote:
I wrote an internal CL command that takes an SQL SELECT statement and
populates an XLSX spreadsheet file.
CMD -> CLP -> PASE -> Python -> Python script
It was quite easy; I had the general notion stubbed out and working with
print statements within minutes. pip install xlsxwriter worked a treat.
Working through the details took most of a day and that includes testing.
The Python script uses ibm_db to access DB2 for i. I used the new DB2
service UDTF qsys2.parse_statement() to extract the column names to be
used as the heading row. For 'select *' statements, this returns zero
columns, but the ibm_db2.columns() function will get the column names
from the table itself.
Error handling is very minimal; it's a tool that probably only I will use.
I was going to say that finding the documentation was kind of a pain,
but it's such a new domain to me that I can't judge until I've got used
to the new idiom.
Mixing CLP, Python, DB2, Excel, and the new DB2 services was very easy.
The only thing I wanted to do but didn't was to feed the exit code back
from Python to the CLP.
Altogether, quite a pleasant experience. I really like the short
feedback loop of an interpreted language.
--
--buck
Try wiki.midrange.com <http://wiki.midrange.com/>!
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx <mailto:OpenSource@xxxxxxxxxxxx>
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/opensource <http://lists.midrange.com/mailman/listinfo/opensource>
or email: OpenSource-request@xxxxxxxxxxxx <mailto:OpenSource-request@xxxxxxxxxxxx>
Before posting, please take a moment to review the archives
at http://archive.midrange.com/opensource <http://archive.midrange.com/opensource>.
As an Amazon Associate we earn from qualifying purchases.
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.