Re: Reading column names.

"Andy Chambers" <achambers.home-gM/[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
> Hi, I'm trying to find out how to read the column names of a given table.
>
> I spent about an hour googling but to no avail. Any help is appreciated!

The python database api specifies this

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

The cursor has an attribute `description' that has details about the
types and names of columns for each query executed.  For any table
therefore, you can do

    cursor.execute("select * from table")
    print cursor.description

.. to get the information you require.

Regards,
Andy
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.