× 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.



On Mon, Dec 6, 2021 at 8:31 AM Kevin Bucknum <Kevin@xxxxxxxxxxxxxxxxxxx> wrote:

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

Not sure which one you mean when you say "the db2 one". There are
basically two reasonable choices for connecting to the built-in
database on the IBM i (that is, the QSYS.LIB stuff) from Python. One
is ibm_db_dbi, which is a module within the ibm_db package. The other
is pyodbc. Both ibm_db_dbi and pyodbc provide an interface conforming
to PEP 249:

https://www.python.org/dev/peps/pep-0249/

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

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

The `description` attribute of the cursor object is one of the things
specified by PEP 249; it's not specific to ibm_db_dbi.

It's a good thing to be aware of, because if you just need the column
name or simple type information, then `description` is probably the
easiest way to get it.

If, like OP, you want the DDS column headings, then you have to look elsewhere.

John Y.

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-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.