Re: testing for table existence

Martin Jenkins <pysqlite-Vfh7fEhEWOlaa/[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Organization XQP Ltd
Message-ID <[email protected]>
Eric S. Johansson 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?

CREATE TABLE IF NOT EXISTS table-name is your friend.

Check out http://www.sqlite.org/lang_createtable.html

Martin
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.