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

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

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

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:
    843
    Bob Foster
    Dec 24, 2003
  2. Bengt Richter
    Replies:
    0
    Views:
    528
    Bengt Richter
    Jul 7, 2005
  3. Jacol

    raise or not to raise [Newbie]

    Jacol, Feb 3, 2007, in forum: Python
    Replies:
    5
    Views:
    654
    Gabriel Genellina
    Feb 5, 2007
  4. Tim Chase
    Replies:
    2
    Views:
    332
    News123
    Dec 14, 2008
  5. Daniel Fetchinson

    Re: 1 or 1/0 doesn't raise an exception

    Daniel Fetchinson, Dec 14, 2008, in forum: Python
    Replies:
    5
    Views:
    405
    Tim Rowe
    Dec 15, 2008
  6. Gabriel Genellina

    Re: 1 or 1/0 doesn't raise an exception

    Gabriel Genellina, Dec 14, 2008, in forum: Python
    Replies:
    2
    Views:
    357
  7. ernest
    Replies:
    2
    Views:
    445
    Roy Smith
    Nov 14, 2010
  8. Jack Bates
    Replies:
    0
    Views:
    447
    Jack Bates
    May 2, 2011
Loading...