MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » December 2013

RE: SQL output to csv



fixed

<Smile> Thank you, Jon and Susan. </Smile>

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Jon Paris
Sent: Thursday, December 05, 2013 8:34 AM
To: Midrange Systems Technical Discussion
Subject: Re: SQL output to csv

<Blush> - Thank you. </Blush>

By the way - we also have a similar CSV reader which I intend to expand further in the future but a few people have already used it as the foundation for an in-house utility. You can find the first one here:

http://www.ibmsystemsmag.com/ibmi/developer/rpg/input_handlers/ (Tiny URL is http://tinyurl.com/OpenAccessCSVSimpleReader)

The followup article which allows the CSV to contain a header row and the fields to be in an arbitrary order is here:

http://www.ibmsystemsmag.com/ibmi/developer/rpg/flexible_input_handlers/ (Tiny URL is http://tinyurl.com/OpenAccessCSVBetterReader)



On 2013-12-05, at 8:27 AM, Gary Thompson <gthompson@xxxxxxxxxxx> wrote:

Thanks John Y. for the re-post >I hope I got that right<, I plan to
use the article to implement our first use of Open Access - and get a
shop utility as a bonus, and kudos for the work of Jon Paris and Susan
Gantner >

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of rob@xxxxxxxxx
Sent: Thursday, December 05, 2013 5:06 AM
To: Midrange Systems Technical Discussion
Subject: Re: SQL output to csv

Looks nice. So, how does that handle these column types:
CLOB
BINARY
DATALINK
I ran into some of these just last week trying to use iNav's Export.
I suppose you have to CAST, like I did when I used the export, right?


Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1 Group Dekko Dept 1600 Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





From: John Yeung <gallium.arsenide@xxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 12/04/2013 05:26 PM
Subject: Re: SQL output to csv
Sent by: midrange-l-bounces@xxxxxxxxxxxx



On Wed, Dec 4, 2013 at 4:23 PM, Gary Thompson <gthompson@xxxxxxxxxxx>
wrote:
Jon,
You got my attention also, but the link seems incomplete...
maybe you can re-post ?

http://www.ibmsystemsmag.com/ibmi/developer/rpg/Getting-a-Handle-on-RP
G%E2%80%99s-Open-Access/


The tricky character in the link is one of those slanted/curved right
single-quotes (for the apostrophe in "RPG's").

Since we're mentioning alternatives, I'll bring up again
iSeriesPython. Use SQL or RLA to access your physical file, use the
built-in CSV module to write out to IFS stream file. For my taste,
using SQL in Python is not as ugly as using it in RPG, and the CSV
module not as involved as Open Access. The whole thing would look
like

import csv, db2
connection = db2.connect()
c1 = connection.cursor()
c1.execute('select * from mylib.myfile') with open('output.csv', 'wb')
as f:
writer = csv.writer(f)
for row in c1.fetchall():
writer.writerow(row)

And you're done. Eight lines for the entire program.

John
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/midrange-l.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/midrange-l.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/midrange-l.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com




--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot 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 here. If you have questions about this, please contact