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

R

Ravi

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

Tim Harig

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

MRAB

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top