Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'schema': 0.05; 'suppose': 0.07; 'exist,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'burak': 0.16; 'guessing': 0.16; 'message- id:@4ax.com': 0.16; 'pythonic': 0.16; 'query,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:flow': 0.16; 'then?': 0.16; 'library': 0.18; 'bit': 0.19; 'thu,': 0.19; 'seems': 0.21; 'new,': 0.24; 'url:home': 0.24; 'query': 0.26; 'shown': 0.26; 'header:X-Complaints-To:1': 0.27; "doesn't": 0.30; "i'm": 0.30; 'table': 0.34; "i'd": 0.34; 'could': 0.34; 'something': 0.35; 'case,': 0.35; 'version': 0.36; 'charset :us-ascii': 0.36; 'so,': 0.37; 'received:76': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'catch': 0.60; 'new': 0.61; 'simply': 0.61; 'kind': 0.63; 'such': 0.63; 'caused': 0.69; 'ugly,': 0.84; 'victor': 0.84; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Try-except for flow control in reading Sqlite Date: Thu, 31 Oct 2013 22:45:05 -0400 Organization: IISS Elusive Unicorn References: <8f70ed52-a4ac-45f6-83b0-76a058074454@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-249-28-245.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383273905 news.xs4all.nl 15923 [2001:888:2000:d::a6]:53772 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58230 On Thu, 31 Oct 2013 16:08:38 -0700 (PDT), Victor Hooi declaimed the following: >Hi, > >You're right, if the databse doesn't exist, the sqlite3 library will simply create it. > >Hmm, in that case, what is the Pythonic way to handle this then? > >If the database is new, then it won't have the table I need, and it will return something like: > > sqlite3.OperationalError: no such table: my_table > >I suppose I can try the query, and catch OperationalError, and if so, create the new schema then? > >However, that seems a bit ugly, as I'm guessing OperationalError could be caused by a number of other reasons? > >Should I perhaps be using some kind of version table as Burak Aslan suggested? > >Cheers, >victor > I'd use the capabilities of the database engine to query it for any existing schema. As shown in my prior post... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/