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

Discussion in 'Python' started by Ravi, Nov 13, 2010.

  1. Ravi

    Ravi Guest

    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.
     
    Ravi, Nov 13, 2010
    #1
    1. Advertising

  2. Ravi

    Tim Harig Guest

    Re: sqlite3 doesn't raise exception if database is notpresent/inaccessible

    On 2010-11-13, Ravi <> 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.
     
    Tim Harig, Nov 13, 2010
    #2
    1. Advertising

  3. Ravi

    MRAB Guest

    Re: sqlite3 doesn't raise exception if database isnot present/inaccessible

    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?
     
    MRAB, Nov 13, 2010
    #3
  4. Ravi

    Ravi Guest

    I understand it now. Thanks for the responses.
     
    Ravi, Nov 13, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ralf Wahner
    Replies:
    5
    Views:
    646
    Bob Foster
    Dec 24, 2003
  2. Jacol

    raise or not to raise [Newbie]

    Jacol, Feb 3, 2007, in forum: Python
    Replies:
    5
    Views:
    417
    Gabriel Genellina
    Feb 5, 2007
  3. ernest
    Replies:
    2
    Views:
    298
    Roy Smith
    Nov 14, 2010
  4. Jack Bates
    Replies:
    0
    Views:
    286
    Jack Bates
    May 2, 2011
  5. bvdp

    Raise X or Raise X()?

    bvdp, Mar 11, 2012, in forum: Python
    Replies:
    10
    Views:
    386
    Stefan Behnel
    Mar 12, 2012
Loading...

Share This Page