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