Re: How can one detect which tables are in a database?
Andy Chambers <andychambers2002-/[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
You can query the table sqlite_master using various values for the type e.g. select name from sqlite_master where type = 'table' or type = 'view' More more detail, see the faq on http://sqlite.org Regards, Andy --- Charles D Hixson <[email protected]> wrote: > In Postgresql I could do: > def listTables(conn): > """ given a database connection, list the tables included in that > database """ > sql = \ > """select c.relname FROM pg_catalog.pg_class c > LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace > WHERE c.relkind IN ('r','') AND n.nspname NOT IN ('pg_catalog', > 'pg_toast') > AND pg_catalog.pg_table_is_visible(c.oid); > """ > cur = conn.cursor() > cur.execute(sql) > tables = cur.fetchall() > return list( (tbl[0] for tbl in tables) ) > > but this is dependent upon various features of Postgresql. Still, it > shows the kind of function I'm after. Any suggestions? Any references? > > _______________________________________________ > pysqlite mailing list > pysqlite-IAPFreCvJWPBWskQ1e/[email protected] > http://lists.initd.org/mailman/listinfo/pysqlite > ___________________________________________________________ Try the all-new Yahoo! Mail. "The New Version is radically easier to use" The Wall Street Journal http://uk.docs.yahoo.com/nowyoucan.html