Re: Reading column names.
"Milo Pschigoda" <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
I don't remember where I got this script, but it does the job for me.
It is more for a human viewer, but I'm sure a little text manipulation
would get the column names into variables
--MilesP
#! /usr/bin/python
from pysqlite2 import dbapi2 as sqlite
con=sqlite.connect("db.databasename")
cur=con.cursor()
sc="select sql from (select * from sqlite_master ) where type!='meta'
order by tbl_name, type DESC, name"
cur.execute(sc)
d=cur.fetchone()
while(d):
print(d)
d=cur.fetchone()
On 1/30/07, Colin Barnette <[email protected]> wrote:
> 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!
>
> Thanks,
>
> Colin Barnette
> _______________________________________________
> pysqlite mailing list
> pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
> http://lists.initd.org/mailman/listinfo/pysqlite
>