Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > sqlite3 doesn't raise exception if database is not present/inaccessible

Reply
Thread Tools

sqlite3 doesn't raise exception if database is not present/inaccessible

 
 
Ravi
Guest
Posts: n/a
 
      11-13-2010
try this:

import sqlite3
con = sqlite3.connect("any string here")

and there is no error reported. You will get an error you do some
operations on the database which is confusing. I think sqlite3 should
change this behavior.
 
Reply With Quote
 
 
 
 
Tim Harig
Guest
Posts: n/a
 
      11-13-2010
On 2010-11-13, Ravi <(E-Mail Removed)> wrote:
> import sqlite3
> con = sqlite3.connect("any string here")


That is a property of the sqlite database itself. It always opens the
database requested; even if it has to create a new database to do so.

> and there is no error reported. You will get an error you do some


If you are conserned about it, check that the database contains the schema
that you were expecting before trying any other operations on it.

> operations on the database which is confusing. I think sqlite3 should
> change this behavior.


If you believe that, you should talk to the sqlite3 people since this is a
property of the database rather then a Python issue.
 
Reply With Quote
 
 
 
 
MRAB
Guest
Posts: n/a
 
      11-13-2010
On 13/11/2010 16:54, Ravi wrote:
> try this:
>
> import sqlite3
> con = sqlite3.connect("any string here")
>
> and there is no error reported. You will get an error you do some
> operations on the database which is confusing. I think sqlite3 should
> change this behavior.


That will open an existing database or create a new one. If it raised
an exception then how would you create a new database?
 
Reply With Quote
 
Ravi
Guest
Posts: n/a
 
      11-13-2010
I understand it now. Thanks for the responses.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Raise X or Raise X()? bvdp Python 10 03-12-2012 04:08 PM
"raise (type, value, traceback)" and "raise type, value, traceback" Jack Bates Python 0 05-02-2011 05:23 PM
raise Exception or raise Exception() ernest Python 2 11-14-2010 08:14 PM
raise or not to raise [Newbie] Jacol Python 5 02-05-2007 11:46 PM
method for Exception base class to raise the exception in an expression? Bengt Richter Python 0 07-07-2005 05:07 PM



Advertisments