Re: testing for table existence
"Colin Barnette" <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
I have a function I use which returns a list of the table names via
the sqlite_master table, hope this helps!
def list_tables(self):
""" List all tables (Permanent and Temporary). """
self.cur.execute("SELECT name FROM (SELECT * FROM
sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE
type='table' ORDER BY name")
tlist = self.cur.fetchall()
return tlist
On 2/25/07, Eric S. Johansson <[email protected]> wrote:
> maybe this is also part of my naïveté with pysqlite but wouldn't your
> code want to test for table existence before creating it? How would I
> do this? I also know test then create is a race condition. Should I do
> anything other than handle an exception?
> --
> Speech-recognition in use. It makes mistakes, I correct some.
> _______________________________________________
> pysqlite mailing list
> pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
> http://lists.initd.org/mailman/listinfo/pysqlite
>