Here is another way if you use the dbi connector. I think there is something similar for the db2 one.

#!/usr/bin/env python3

import ibm_db_dbi as db2

query = "select cusnum, lstnam as Last_Name, init, cdtlmt, qc.* from qiws.qcustcdt qc where cdtlmt > 100"

conn = db2.connect()
cur = conn.cursor()
cur.execute(query)

for column_variable in cur.description:
column_name = column_variable[0]
print(column_name)


Last two lines are indented. if you run that, you will see that it pulls the renamed column as well as the generic columns selected with the *


On Sat, 2021-12-04 at 17:22 -0500, John Yeung wrote:
On Fri, Dec 3, 2021 at 6:47 PM Roger Harman <roger.harman@xxxxxxxxxxx<mailto:roger.harman@xxxxxxxxxxx>> wrote:

I'll be interested in seeing the Python solution with COLHDG() and formatting them as multi-line headers in Excel.

I'm swamped right now, but when I get a chance, I'll throw something
together for this. Though if someone else wants to take a stab at it
before I get around to it, by all means go ahead.

John Y.

[https://www.medtronsoftware.com/img/MedtronMinilogo.bmp]
Kevin Bucknum

Senior Programmer Analyst

MEDDATA / MEDTRON

120 Innwood Drive
Covington LA 70433
Local: 985-893-2550<tel:985-893-2550>
Toll Free: 877-893-2550<tel:877-893-2550>
https://www.medtronsoftware.com


CONFIDENTIALITY NOTICE

This document and any accompanying this email transmission contain confidential information, belonging to the sender that is legally privileged. This information is intended only for the use of the individual or entity named above. The authorized recipient of this information is prohibited from disclosing this information to any other party and is required to destroy the information after its stated need has been fulfilled. If you are not the intended recipient, or the employee of agent responsible to deliver it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or action taken in reliance on the contents of these documents is STRICTLY PROHIBITED. If you have received this email in error, please notify the sender immediately to arrange for return or destruction of these documents.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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

This mailing list archive is Copyright 1997-2022 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.