Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58230
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: Try-except for flow control in reading Sqlite |
| Date | 2013-10-31 22:45 -0400 |
| Organization | IISS Elusive Unicorn |
| References | <ac7cf18f-d4f4-41ef-966d-a35d2d0e39a8@googlegroups.com> <mailman.1728.1383003802.18130.python-list@python.org> <8f70ed52-a4ac-45f6-83b0-76a058074454@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1903.1383273905.18130.python-list@python.org> (permalink) |
On Thu, 31 Oct 2013 16:08:38 -0700 (PDT), Victor Hooi
<victorhooi@gmail.com> 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/
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Try-except for flow control in reading Sqlite Victor Hooi <victorhooi@gmail.com> - 2013-10-27 20:43 -0700
Re: Try-except for flow control in reading Sqlite Steven D'Aprano <steve@pearwood.info> - 2013-10-28 06:18 +0000
Re: Try-except for flow control in reading Sqlite Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-28 10:48 +0100
Re: Try-except for flow control in reading Sqlite Chris Angelico <rosuav@gmail.com> - 2013-10-28 17:36 +1100
Re: Try-except for flow control in reading Sqlite Victor Hooi <victorhooi@gmail.com> - 2013-10-27 23:57 -0700
Re: Try-except for flow control in reading Sqlite Chris Angelico <rosuav@gmail.com> - 2013-10-28 18:01 +1100
Re: Try-except for flow control in reading Sqlite Steven D'Aprano <steve@pearwood.info> - 2013-10-28 07:19 +0000
Re: Try-except for flow control in reading Sqlite Chris Angelico <rosuav@gmail.com> - 2013-10-28 18:02 +1100
Re: Try-except for flow control in reading Sqlite Burak Arslan <burak.arslan@arskom.com.tr> - 2013-10-28 10:17 +0200
Re: Try-except for flow control in reading Sqlite Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-28 19:43 -0400
Re: Try-except for flow control in reading Sqlite Victor Hooi <victorhooi@gmail.com> - 2013-10-31 16:08 -0700
Re: Try-except for flow control in reading Sqlite Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-31 22:45 -0400
csiph-web